Function randomPassword

Generates a random password.

This is limited to generating ASCII passwords. This is because including non-ASCII characters in generated passwords is more complex, more error-prone, more likely to trigger latent unicode bugs in other systems, and not particularly useful anyway.

Throws an Exception if passwordChars.length isn't at least 2.

USE THIS RESPONSIBLY! NEVER EMAIL THE PASSWORD! Emailing a generated password to a user is a highly insecure practice and should NEVER be done. However, there are other times when generating a password may be reasonable, so this is provided as a convenience.

Prototypes

Password randomPassword(Rand)(
  size_t length,
  const(ubyte)[] passwordChars
);

Password randomPassword(Rand)(
  ref Rand rand,
  size_t length,
  const(ubyte)[] passwordChars
);

void randomPassword(Rand, Sink)(
  ref Sink sink,
  size_t length,
  const(ubyte)[] passwordChars
);

void randomPassword(Rand, Sink)(
  ref Rand rand,
  ref Sink sink,
  size_t length,
  const(ubyte)[] passwordChars
);

Optional Params

Rand - Default value is 'DefaultCryptoRand'

length - Default value is 'defaultPasswordLength'

passwordChars - Default value is 'defaultPasswordChars'

Authors

Copyright

License