dauth.random

DAuth - Salted Hashed Password Library for D Random generators

Members

Functions

randomBytes
ubyte[] randomBytes(size_t numBytes, ref Rand rand)

numBytes must be a multiple of 4, or this will throw an Exception

randomBytes
ubyte[] randomBytes(size_t numBytes)

numBytes must be a multiple of 4, or this will throw an Exception

randomPassword
Password randomPassword(size_t length = defaultPasswordLength, const(ubyte)[] passwordChars = defaultPasswordChars)
Password randomPassword(ref Rand rand, size_t length = defaultPasswordLength, const(ubyte)[] passwordChars = defaultPasswordChars)
void randomPassword(ref Sink sink, size_t length = defaultPasswordLength, const(ubyte)[] passwordChars = defaultPasswordChars)
void randomPassword(ref Rand rand, ref Sink sink, size_t length = defaultPasswordLength, const(ubyte)[] passwordChars = defaultPasswordChars)

Generates a random password.

randomSalt
Salt randomSalt(size_t length = defaultSaltLength)
Salt randomSalt(ref Rand rand, size_t length = defaultSaltLength)

Generates a random salt. Necessary for salting passwords.

randomToken
string randomToken(size_t strength = defaultTokenStrength)
string randomToken(ref Rand rand, size_t strength = defaultTokenStrength)

Generates a random token. Useful for temporary one-use URLs, such as in email confirmations.

Manifest constants

defaultPasswordChars
enum defaultPasswordChars;

Punctuation is not included in generated passwords by default. Technically, this is slightly less secure for a given password length, but it prevents syntax-related bugs when a generated password is stored in a (properly-secured) text-based configuration file.

defaultPasswordLength
enum defaultPasswordLength;

In characters. Default length of randomly-generated passwords.

defaultSaltLength
enum defaultSaltLength;

In bytes. Must be a multiple of 4.

defaultTokenStrength
enum defaultTokenStrength;

In bytes of randomness, not length of token. Must be a multiple of 4. Although, due to usage of base64, using a multiple of 12 prevents a padding tilde from existing at the end of every token.

Meta