rsaEncrypt static method
rsa加密
publicKey rsa 公钥
data 需要加密的内容
Implementation
static String? rsaEncrypt(String publicKey, String data ) {
try {
RSAPublicKey key = RSAKeyParser().parse(publicKey) as RSAPublicKey;
var encrypter = Encrypter(RSA(publicKey: key));
var encrypted = encrypter.encrypt(data);
return encrypted.base64;
} catch (e) {
return null;
}
}