/// <summary> /// 按PKCS#1格式生成RSA公钥并进行BASE64转换 /// </summary> /// <param name="n"></param> /// <param name="e"></param> /// <returns></returns> public static string PKCS1_Pub_Gen_S(BigInteger n, BigInteger e) { string strPKCS = new string(Encoding.UTF8.GetChars(BASE64_Main.EncryptB(PKCS1_Pub_Gen(n, e)))); int count = 64; while (count < strPKCS.Length) { strPKCS = strPKCS.Insert(count, "\n"); count += 65; } strPKCS = "-----BEGIN RSA PUBLIC KEY-----\n" + strPKCS + "\n-----END RSA PUBLIC KEY-----\n"; return(strPKCS); }
/// <summary> /// 按PKCS#1格式生成RSA私钥并进行BASE64转换 /// </summary> /// <returns></returns> public static string PKCS1_Pri_Gen_S() { string strPKCS = new string(Encoding.UTF8.GetChars(BASE64_Main.EncryptB(PKCS1_Pri_Gen()))); int count = 64; while (count < strPKCS.Length) { strPKCS = strPKCS.Insert(count, "\n"); count += 65; } strPKCS = "-----BEGIN RSA PRIVATE KEY-----\n" + strPKCS + "\n-----END RSA PRIVATE KEY-----\n"; return(strPKCS); }