Open EpicGamer1YT opened 5 years ago
API for AsymmetricKeyPair is here: https://pub.dartlang.org/documentation/pointycastle/latest/pointycastle.api/AsymmetricKeyPair-class.html
You can see that the keypair object has .privateKey and .publicKey members, and each of those has BigInt members for its values.
I would like to know too.
See SO question/answer here
how do I get the values of the generated key pair
Cast them into their actual classes. Cast the publicKey member from a PublicKey into an RSAPublicKey, and the privateKey member from a PrivateKey into an RSAPrivateKey.
The example below uses the Dart as
keyword to perform this casting.
RSAKeyGenerator keyGen = ...
final pair = keyGen.generateKeyPair(); // produces an AsymmetricKeyPair
// Examine the generated key-pair
final rsaPublic = pair.publicKey as RSAPublicKey;
final rsaPrivate = pair.privateKey as RSAPrivateKey;
print('Generated ${keyGen.algorithmName} key:');
print(' Public:');
print(' e = ${rsaPublic.exponent}'); // public exponent
print(' n = ${rsaPublic.modulus}');
print(' Private: n.bitlength = ${rsaPrivate.modulus.bitLength}');
print(' n = ${rsaPrivate.modulus}');
print(' d = ${rsaPrivate.exponent}'); // private exponent
print(' p = ${rsaPrivate.p}'); // the two prime numbers
print(' q = ${rsaPrivate.q}');
Since this is an RSA key pair, the numbers have these properties:
After generating a key pair and encrypting the test "Hello World" String, how do I get the values of the generated key pair(private and public key values)? it only tells me
Instance of 'RSAPublicKey'
when I try to print it to the console.Here is my sample code: