generateRandomPrivateAndPublicKeyPair function

Tuple2<String, String> generateRandomPrivateAndPublicKeyPair()

Implementation

Tuple2<String, String> generateRandomPrivateAndPublicKeyPair() {
  final kp = RSAKeypair.fromRandom();

  var strPriv = kp.privateKey.toPEM().replaceAllMapped(RegExp(r'-----.+?-----'), (match) => '').replaceAll('\n', '');
  var hexPriv = base64Decode(strPriv).toHexString();
  var strPub = kp.publicKey.toPEM().replaceAllMapped(RegExp(r'-----.+?-----'), (match) => '').replaceAll('\n', '');
  var hexPub = base64Decode(strPub).toHexString();

  return Tuple2(hexPriv, hexPub);
}