RsaHelperGetKey 方法

生成一对新的 RSA 密钥(公钥 + 私钥)。

Definition

命名空间: Suresking.Utility
程序集: Suresking.Utility (在 Suresking.Utility.dll 中) 版本:1.3.22+a27276bb8ffde055e69ff608e98aafba279e1e99
C#
public static Dictionary<string, string> GetKey()

返回值

DictionaryString, String
包含两个键的字典:"PublicKey"(公钥)与 "PrivateKey"(私钥), 值均为 CSP Blob 的 Base64 字符串,可直接传给 Encrypt(String, String) / Decrypt(String, String)。

备注

使用 RSACryptoServiceProvider 默认密钥长度(通常为 1024 或 2048 位,取决于系统默认值)。

安全提示:私钥必须妥善保管,切勿泄露;建议显式指定足够强度的密钥长度(如 2048 或 4096 位), 可通过带参数的 RSACryptoServiceProvider(int dwKeySize) 构造函数实现。

参见