コード例 #1
0
        /// <summary>
        /// 通过PKCS#1私钥进行加密,可以指定密文字符串分组间的分隔符,默认为'&'
        /// </summary>
        /// <param name="PKCS1_Pri_Key"></param>
        /// <param name="strCipher"></param>
        /// <param name="strCoding"></param>
        /// <param name="chSplit"></param>
        /// <returns></returns>
        public static string Decrypt_PKCS1_S(string PKCS1_Pri_Key, string strCipher, string strCoding, char chSplit = '&')
        {
            RSA_Cipher rsaCipher = new RSA_Cipher(strCipher, chSplit);

            BigInteger[] RSA_PriKey = RSA_Read.PKCS1_Pri_Read(PKCS1_Pri_Key);
            ByteString   bsPlain    = new ByteString();

            foreach (BigInteger biCipher in rsaCipher.bilData)
            {
                BigInteger biPlain = Decrypt(biCipher, RSA_PriKey[3], RSA_PriKey[1]);
                bsPlain += biPlain.ToByteArray();
            }
            return(new string(Encoding.GetEncoding(strCoding).GetChars(bsPlain.GetBytes())));
        }
コード例 #2
0
        /// <summary>
        /// 通过PKCS#1公钥进行加密,可以指定密文字符串分组间的分隔符,默认为'&'
        /// </summary>
        /// <param name="PKCS1_Pub_Key"></param>
        /// <param name="strPlain"></param>
        /// <param name="strCoding"></param>
        /// <param name="chSplit"></param>
        /// <returns></returns>
        public static string Encrypt_PKCS1_S(string PKCS1_Pub_Key, string strPlain, string strCoding, char chSplit = '&')
        {
            RSA_Plain rsaPlain = new RSA_Plain(strPlain, strCoding);

            BigInteger[]      RSA_PubKey        = RSA_Read.PKCS1_Pub_Read(PKCS1_Pub_Key);
            string            RSA_Cipher        = "";
            List <BigInteger> RSA_Cipher_Origin = new List <BigInteger>();

            foreach (BigInteger biPlain in rsaPlain.bilData)
            {
                BigInteger biCipher = Encrypt(biPlain, RSA_PubKey[1], RSA_PubKey[0]);
                RSA_Cipher_Origin.Add(biCipher);
                RSA_Cipher += (biCipher).ToString() + chSplit;
            }
            RSA_Cipher = RSA_Cipher.Remove(RSA_Cipher.Length - 1);
            return(RSA_Cipher);
        }
コード例 #3
0
ファイル: RSA_Gen.cs プロジェクト: PixelFrame/CryptoSharp
 /// <summary>
 /// 通过PKCS#1格式私钥生成公钥并进行BASE64转换
 /// </summary>
 /// <param name="strPKCS1Pri"></param>
 /// <returns></returns>
 public static string PKCS1_Pub_Gen_S(string strPKCS1Pri)
 {
     BigInteger[] RSA_Key = RSA_Read.PKCS1_Pri_Read(strPKCS1Pri);
     return(PKCS1_Pub_Gen_S(RSA_Key[1], RSA_Key[2]));
 }
コード例 #4
0
ファイル: RSA_Gen.cs プロジェクト: PixelFrame/CryptoSharp
 /// <summary>
 /// 通过PKCS#1格式私钥生成公钥并进行BASE64转换
 /// </summary>
 /// <param name="baPKCS1Pri"></param>
 /// <returns></returns>
 public static string PKCS1_Pub_Gen_S(byte[] baPKCS1Pri)
 {
     BigInteger[] RSA_Key = RSA_Read.PKCS1_Read(baPKCS1Pri);
     return(PKCS1_Pub_Gen_S(RSA_Key[1], RSA_Key[2]));
 }