Пример #1
0
        /// <summary>
        /// 创建密钥
        /// </summary>
        /// <returns></returns>
        public override AsymmetricKey CreateKey(RSAKeySizeType size = RSAKeySizeType.L2048)
        {
            var key = RSAEncryptionProvider.CreateKey(size, KeyType);

            return(new AsymmetricKey()
            {
                PrivateKey = key.PrivateKey, PublickKey = key.PublickKey
            });
        }
Пример #2
0
 /// <summary>
 /// 使用指定公钥验证解密得到的明文是否符合签名
 /// </summary>
 /// <param name="source">解密得到的明文</param>
 /// <param name="signData">明文签名字符串</param>
 /// <param name="publicKey">公钥</param>
 /// <returns></returns>
 public override bool VerifyData(string source, string signData, string publicKey)
 {
     return(RSAEncryptionProvider.VerifyData(source, signData, publicKey, Encoding, OutType, RSAType.RSA2, KeyType));
 }
Пример #3
0
 /// <summary>
 /// 使用指定密钥对明文进行签名,返回明文签名的字符串
 /// </summary>
 /// <param name="source">要签名的明文字符串</param>
 /// <param name="privateKey">私钥</param>
 /// <returns></returns>
 public override string SignData(string source, string privateKey)
 {
     return(RSAEncryptionProvider.SignData(source, privateKey, Encoding, OutType, RSAType.RSA2, KeyType));
 }
Пример #4
0
 /// <summary>
 /// 使用指定私钥解密字符串
 /// </summary>
 /// <param name="value">要解密的密文字符串</param>
 /// <param name="privateKey">私钥</param>
 /// <param name="encoding">编码类型</param>
 /// <param name="outType">输出类型</param>
 /// <param name="keyType">密钥类型</param>
 /// <returns></returns>
 public override string Decrypt(string value, string privateKey)
 {
     return(RSAEncryptionProvider.Decrypt(value, privateKey, Encoding, OutType, KeyType));
 }
Пример #5
0
 /// <summary>
 /// 使用指定公钥加密字符串
 /// </summary>
 /// <param name="value">要加密的明文字符串</param>
 /// <param name="publicKey">公钥</param>
 /// <param name="encoding">编码类型</param>
 /// <param name="outType">输出类型</param>
 /// <param name="keyType">密钥类型</param>
 /// <returns></returns>
 public override string Encrypt(string value, string publicKey)
 {
     return(RSAEncryptionProvider.Encrypt(value, publicKey, Encoding, OutType, KeyType));
 }