Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 通过PKCS#1格式私钥生成公钥
 /// </summary>
 /// <param name="strPKCS1Pri"></param>
 /// <returns></returns>
 public static byte[] PKCS1_Pub_Gen(string strPKCS1Pri)
 {
     BigInteger[] RSA_Key = RSA_Read.PKCS1_Pub_Read(strPKCS1Pri);
     return(PKCS1_Pub_Gen(RSA_Key[1], RSA_Key[2]));
 }