opensslEncrypt static method
Implementation
static String opensslEncrypt(Map<String, dynamic> data, String publickey) {
final parser = RSAKeyParser();
final encrypter = Encrypter(RSA(
publicKey: parser.parse(publickey) as RSAPublicKey,
digest: RSADigest.SHA256,
));
var codeUnits = json.encode(data).codeUnits;
List<int> source = utf8.encode(String.fromCharCodes(codeUnits));
List<int> result = [];
//Assumes 1024 bit key and encrypts in chunks.
source.splitByLength(117).forEach((input) {
var output = encrypter.encryptBytes(input);
result = [...result, ...output.bytes.toList()];
});
return base64.encode(result);
}