Closed bahman2000 closed 8 months ago
@bahman2000 Take a look at the following package : https://github.com/Ephenodrom/Dart-Basic-Utils
This is basically a wrapper package around pointycastle, offering some methods to convert keys to PEM strings. Take a look at the CryptoUtils class. There are methods like "encodeRSAPrivateKeyToPem" that take a RSAPrivateKey from pointycastle.
This is a method to generate an RSA key pair:
AsymmetricKeyPair<PublicKey, PrivateKey> getRsaKeyPair( SecureRandom secureRandom) { var rsaparams = RSAKeyGeneratorParameters(BigInt.from(65537), 4096, 5); var params = ParametersWithRandom(rsaparams , secureRandom); var keyGenerator = RSAKeyGenerator(); keyGenerator.init(params); return keyGenerator.generateKeyPair(); }
How can I convert
PublicKey
andPrivateKey
objects to string?