newKeyPair method

  1. @override
Future<SimpleKeyPair> newKeyPair()
override

Generates a new KeyPair that can be used with this algorithm.

Example

In this example, we use X25519:

import 'package:cryptography/cryptography.dart';

Future<void> main() async {
  final algorithm = X25519();
  final keyPair = await algorithm.newKeyPair();
}

Implementation

@override
Future<SimpleKeyPair> newKeyPair() {
  final seed = Uint8List(keyPairType.privateKeyLength);
  fillBytesWithSecureRandom(seed, random: _random);
  return newKeyPairFromSeed(seed);
}