generateMnemonic function

String generateMnemonic(
  1. Random random, {
  2. int strength = 128,
  3. String language = 'english',
})

This function generates a mnemonic with the given strength, language, and random number generator function (to generate random entropy). Developers should note that if you use Random.secure(), it might not be supported on all platforms (since under the hood it uses a native implementation which does not exist for some platforms i.e cross-compilation to Node).

Implementation

String generateMnemonic(Random random,
    {int strength = 128, String language = 'english'}) {
  assert(strength % 32 == 0);
  final entropy = Entropy.generate(
      from_entropy_size(strength), RandomBridge(random).nextUint8);
  return entropyToMnemonic(HexCoder.instance.encode(entropy.bytes),
      language: language);
}