You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The function 'RSAKeyParser' isn't defined.
Try importing the library that defines 'RSAKeyParser', correcting the name to the name of an existing function, or defining a function named 'RSAKeyParser'.dartundefined_function
import 'package:pointycastle/export.dart' as crypto;
String encryptWithPublicKey(String publicKeyPem, String text) {
// Create an RSA public key from the PEM string
crypto.RSAKeyParser keyParser = crypto.RSAKeyParser();
crypto.RSAPublicKey publicKey = keyParser.parse(publicKeyPem) as crypto.RSAPublicKey;
// Configure the OAEP encoder with SHA-256
crypto.OAEPEncoding oaep = crypto.OAEPEncoding(crypto.RSAEngine())
..init(true, crypto.PublicKeyParameter<crypto.RSAPublicKey>(publicKey)); // true for encryption
// Convert text to bytes
Uint8List data = Uint8List.fromList(utf8.encode(text));
// Encrypt the data
Uint8List encrypted = oaep.process(data);
// Encode encrypted bytes to base64
return base64Encode(encrypted);
}
The text was updated successfully, but these errors were encountered:
In following code it gives me error of
The function 'RSAKeyParser' isn't defined.
Try importing the library that defines 'RSAKeyParser', correcting the name to the name of an existing function, or defining a function named 'RSAKeyParser'.dartundefined_function
import 'package:pointycastle/export.dart' as crypto;
String encryptWithPublicKey(String publicKeyPem, String text) {
// Create an RSA public key from the PEM string
crypto.RSAKeyParser keyParser = crypto.RSAKeyParser();
crypto.RSAPublicKey publicKey = keyParser.parse(publicKeyPem) as crypto.RSAPublicKey;
}
The text was updated successfully, but these errors were encountered: