嗨,谁能告诉我如何使用 c# 中的充气城堡生成 pgp 公共、私人和密码短语?
问问题
1146 次
1 回答
2
这应该这样做:)
//DSA Key Pair Generator
DsaKeyPairGenerator a = new DsaKeyPairGenerator();
//DSA Key Parameter Generator
DsaParametersGenerator paramgen = new DsaParametersGenerator();
//Initialize Key Parameter Generator
paramgen.Init(512, 100, new SecureRandom());
//DSA KeyGeneration Parameters
DsaKeyGenerationParameters param = new DsaKeyGenerationParameters(new SecureRandom(), paramgen.GenerateParameters());
//Initialize the Key Pair Generator
a.Init(param);
//The DSA Keys!
AsymmetricCipherKeyPair keys = a.GenerateKeyPair();
//PGP PubKey
PgpPublicKey pub = new PgpPublicKey(Org.BouncyCastle.Bcpg.PublicKeyAlgorithmTag.Dsa, keys.Public, DateTime.Now);
//PGP PrivKey
PgpPrivateKey priv = new PgpPrivateKey(keys.Private, pub.KeyId);
于 2009-06-09T11:09:22.933 回答