rsa_cipher 1.2.2
rsa_cipher: ^1.2.2 copied to clipboard
rsa_cipher is a powerful and easy-to-use package for RSA encryption and decryption in Dart.
import 'package:rsa_cipher/rsa_cipher.dart';
void main() async {
// generate key
final keyPair = RsaCipher().generateKeyPair();
// encode key to pem
final publicKeyPem = keyPair.publicKey.toPem();
final privateKeyPem = keyPair.privateKey.toPem();
// decode pem to key
final publicKey = PublicKey.fromPem(publicKeyPem);
final privateKey = PrivateKey.fromPem(privateKeyPem);
// encrypt text
final cipherText = RsaCipher().encrypt(
plaintext: "hello",
publicKey: publicKey,
);
// decrypt text
final plainText = RsaCipher().decrypt(
ciphertext: cipherText,
privateKey: privateKey,
);
}