decryptByPublicKey function
String?
decryptByPublicKey(
- String data,
- PublicKey publicKey
)
Implementation
String? decryptByPublicKey(String data, PublicKey publicKey) {
try {
// var keyParameter = () => PrivateKeyParameter<RSAPrivateKey>(privateKey);
var keyParameter = () => PublicKeyParameter<RSAPublicKey>(publicKey);
AsymmetricBlockCipher cipher = AsymmetricBlockCipher("RSA/PKCS1");
cipher.reset();
cipher.init(false, keyParameter());
Uint8List bconv = Base64Decoder().convert(data);
final decrypted = cipher.process(bconv);
String res = String.fromCharCodes(decrypted);
return res;
} catch (e) {
print(e.toString());
}
}