Module z_ids

Server supplying random strings and unique ids.

Copyright © 2009-2012 Marc Worrell

Authors: Marc Worrell (marc@worrell.nl).

Description

Server supplying random strings and unique ids

Data Types

charset()

charset() = az | az09 | azAZ09

Function Index

id/0Equivalent to id(?ID_LENGTH).
id/1Generate a random key consisting of numbers and upper and lower case characters.
identifier/0Equivalent to identifier(?OPTID_LENGTH).
identifier/1Get a random identifier of a certain length, consisting of lower case characters only.
number/0Equivalent to number(1000000000).
number/1Return a random integer less than or equal to Max.
optid/1
rand_bytes/1Return N random bytes.
random_id/2Get a random identifier of the specified length, consisting of characters from the specified set: - 'az' [a-z] : lower case characters only.
sign_key/1Get the key for signing requests stored in the user agent.
sign_key_simple/1Get the key for less secure signing of data (without nonce).
unique/0Return an unique id to be used in javascript or html.

Function Details

id/0

id() -> binary()

Equivalent to id(?ID_LENGTH).

id/1

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.

identifier/0

identifier() -> binary()

Equivalent to identifier(?OPTID_LENGTH).

identifier/1

identifier(Length::integer()) -> binary()

Get a random identifier of a certain length, consisting of lower case characters only.

number/0

number() -> integer()

Equivalent to number(1000000000).

number/1

number(Max::integer()) -> integer()

Return a random integer less than or equal to Max. Max defaults to a large number smaller than MaxInt.

optid/1

optid(Id::undefined | false | binary()) -> binary()

rand_bytes/1

rand_bytes(N::integer()) -> binary()

Return N random bytes. This falls back to the pseudo random version of rand_uniform if strong_rand_bytes fails.

random_id/2

random_id(X1::charset(), Length::integer()) -> binary()

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.

sign_key/1

sign_key(Context::term()) -> binary()

Get the key for signing requests stored in the user agent.

sign_key_simple/1

sign_key_simple(Context::term()) -> binary()

Get the key for less secure signing of data (without nonce).

unique/0

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.


Generated by EDoc