Generate random RSA keys with RSACryptoServiceProvider
如何使用rsacryptoServiceProvider类生成随机的rsa公钥和私钥(rsaparameters)?每次我创建rsacryptoServiceProvider的新实例时,都会导出相同的密钥。
谢谢
我对以下代码做了一些测试,导出的参数总是不同的:
1 2 3 4 5 6 7 8 9 10 |
使用以下代码,您永远不应该取出所有相同的钥匙
1 2 |
但是,您应该注意,指数键可以是相同的,如果经常是65537(0x010001)。
"Choose an integer e such that 1 < e < φ(n) and gcd(e, φ(n)) = 1; i.e., e and φ(n) are coprime. e is released as the public key exponent. e having a short bit-length and small Hamming weight results in more efficient encryption – most commonly 216 + 1 = 65,537. However, much smaller values of e (such as 3) have been shown to be less secure in some settings." RSA wiki