z_ids (zotonic_core v1.0.0-rc.10)
Link to this section 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.
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.
Get the key for signing requests stored in the user agent.
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.
Link to this section Types
Link to this type
charset/0
-type charset() :: az | az09 | azAZ09.
Link to this section Functions
-spec id() -> binary().
id(?ID_LENGTH)
.
Link to this function
id(Length)
-spec id(Length :: integer()) -> binary().
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.
Link to this function
identifier()
-spec identifier() -> binary().
identifier(?OPTID_LENGTH)
.
Link to this function
identifier(Length)
-spec identifier(Length :: integer()) -> binary().
Link to this function
number()
-spec number() -> integer().
number(1000000000)
.
Link to this function
number(Max)
-spec number(Max :: integer()) -> integer().
Link to this function
optid(Id)
-spec optid(undefined | false | binary()) -> binary().
Link to this function
rand_bytes(N)
-spec rand_bytes(integer()) -> binary().
Link to this function
random_id(_, Length)
-spec random_id(charset(), Length :: integer()) -> binary().
Link to this function
sign_key(Context)
-spec sign_key(Context :: term()) -> binary().
Link to this function
sign_key_simple(Context)
-spec sign_key_simple(Context :: term()) -> binary().
Link to this function
unique()
-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.