在pgp中生成公共密码,私有密码和密码短语?

时间:2009-05-20 09:25:56

标签: c# bouncycastle

嗨,有谁能告诉我如何使用c#中的充气城堡生成pgp public,private和passphrase?

1 个答案:

答案 0 :(得分: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);