Function randomToken

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

The strength is the number of bytes of randomness in the token. Note this is NOT the length of the token string returned, since this token is base64-encoded (using an entirely URI-safe version that doesn't need escaping) from the raw random bytes.

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

Prototypes

string randomToken(Rand)(
  size_t strength
);

string randomToken(Rand)(
  ref Rand rand,
  size_t strength
);

Optional Params

Rand - Default value is 'DefaultCryptoRand'

strength - Default value is 'defaultTokenStrength'

Authors

Copyright

License