z_ids (zotonic_core v1.0.0-rc.17)
Functions supplying random strings, unique ids and nonce support.
Summary
Functions
Equivalent to id(?ID_LENGTH).
Generate a random key consisting of numbers and upper and lower case characters.
Equivalent to identifier(?OPTID_LENGTH).
Get a random identifier of a certain length, consisting of lower case characters only.
Equivalent to number(1000000000).
Return a random integer less than or equal to Max. Max defaults to a large number smaller than MaxInt.
Generate an identifier if the identifier was not defined.
Generate a password that matches most criteria of complexity and is still (kind of) readable.
Return N random bytes. This falls back to the pseudo random version of rand_uniform if strong_rand_bytes fails.
Get a random identifier of the specified length, consisting of characters from the specified set: - 'az'
Generate a key for signing requests stored in the user agent.
Get the key for signing requests stored in the user agent.
Generate a key for less secure signing of data (without nonce).
Get the key for less secure signing of data (without nonce).
Return an unique id to be used in javascript or html. No randomness, just unique for the current runtime system instance.
Types
Functions
-spec id() -> binary().
Equivalent to id(?ID_LENGTH).
Generate a random key consisting of numbers and upper and lower case characters.
The version with the default Length can be used for session ids: the result is sufficiently random and sufficiently unique.
-spec identifier() -> binary().
Equivalent to identifier(?OPTID_LENGTH).
Get a random identifier of a certain length, consisting of lower case characters only.
-spec number() -> pos_integer().
Equivalent to number(1000000000).
-spec number(Max :: pos_integer()) -> pos_integer().
Return a random integer less than or equal to Max. Max defaults to a large number smaller than MaxInt.
Generate an identifier if the identifier was not defined.
-spec password() -> binary().
Generate a password that matches most criteria of complexity and is still (kind of) readable.
Return N random bytes. This falls back to the pseudo random version of rand_uniform if strong_rand_bytes fails.
Get a random identifier of the specified length, consisting of characters from the specified set: - 'az'
[a-z]: lower case characters only. - 'az09'
[a-z0-9]: lower case characters and numbers only. - 'azAZ09'
[a-zA-Z0-9]: lower and upper case characters and numbers. - '09'
[0-9]: numbers only. - 'special'
[!#$%&()*+/;:<>=?@]: special characters for passwords.
-spec sign_key() -> binary().
Generate a key for signing requests stored in the user agent.
Get the key for signing requests stored in the user agent.
-spec sign_key_simple() -> binary().
Generate a key for less secure signing of data (without nonce).
Get the key for less secure signing of data (without nonce).
-spec unique() -> binary().
Return an unique id to be used in javascript or html. No randomness, just unique for the current runtime system instance.
Returns a binary of unspecified length starting with the character $t followed by a number of digits, example: <<"t123456">>. Note that ids are not unique among connected nodes or after a restart.