rsaEncrypt static method

String rsaEncrypt(
  1. String content,
  2. String publicKeyStr
)

RSA加密算法加密,秘钥格式为pkcs8 content明文 publicKeyStr公钥

Implementation

static String rsaEncrypt(String content, String publicKeyStr) {
  final parser = RSAKeyParser();
  String publicKeyString = _transformPem(publicKeyStr);
  RSAPublicKey publicKey = parser.parse(publicKeyString) as RSAPublicKey;
  final encryptor = Encrypter(RSA(publicKey: publicKey));
  final encrypted = encryptor.encrypt(content);
  return encrypted.base64;
}