/// <summary> /// RSA解密 /// </summary> /// <param name="base64Str">加密过的Base64Str</param> /// <param name="privatekey">私钥(可空)</param> /// <returns>解密内容</returns> public static string Decrypt2String(string base64Str, string privatekey = "") { byte[] byteArr_ToDecrypt = Convert.FromBase64String(base64Str); byte[] byteArr_Decrypted = RSAUtils.Decrypt(byteArr_ToDecrypt, privatekey); return(RSAUtils.sEncoder.GetString(byteArr_Decrypted)); }
/// <summary> /// RSA加密 - 返回Base64Str /// </summary> /// <param name="content">加密内容</param> /// <param name="publickey">公钥(可空)</param> /// <returns>返回Base64Str</returns> public static string Encrypt2Base64Str(string content, string publickey = "") { byte[] byteArr_UTF8Content = RSAUtils.sEncoder.GetBytes(content); byte[] byteArr_Encrypted = RSAUtils.Encrypt(byteArr_UTF8Content, publickey); return(Convert.ToBase64String(byteArr_Encrypted)); }