嗨,有谁能告诉我如何使用c#中的充气城堡生成pgp public,private和passphrase?
答案 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);