Copyright © 2011-2015 Michael Truog
Version: 1.4.1 Apr 12 2015 17:05:53 ------------------------------------------------------------------------
Authors: Michael Truog (mjtruog [at] gmail (dot) com).
state() = #uuid_state{}
timestamp_type() = os | erlang | warp
uuid() = <<_:128>>
| get_v1/1 |
Get a v1 UUID.. |
| get_v1_time/0 |
Get the current time value in a manner consistent with the v1 UUID.The result is an integer in microseconds. |
| get_v1_time/1 |
Get the current time value in a manner consistent with the v1 UUID.The result is an integer in microseconds. |
| get_v3/1 |
Get a v3 UUID.. |
| get_v3/2 |
Get a v3 UUID in a particular namespace.. |
| get_v3_compat/1 |
Get a compatible v3 UUID.Do not use all bits from the checksum so that the UUID matches external implementations. |
| get_v3_compat/2 |
Get a compatible v3 UUID in a particular namespace.Do not use all bits from the checksum so that the UUID matches external implementations. |
| get_v4/0 |
Get a v4 UUID (using crypto/openssl).crypto:strong_rand_bytes/1 repeats in the same way as RAND_bytes within OpenSSL. |
| get_v4/1 | |
| get_v4_urandom/0 |
Get a v4 UUID (using Wichmann-Hill 2006).random_wh06_int:uniform/1 repeats every 2.66e36 (2^121) approx. |
| get_v4_urandom_bigint/0 |
Get a v4 UUID (using Wichmann-Hill 1982).random:uniform/1 repeats every 2.78e13 (see B.A. Wichmann and I.D.Hill, in 'An efficient and portable pseudo-random number generator', Journal of Applied Statistics. AS183. 1982, or Byte March 1987) a single random:uniform/1 call can provide a maximum of 45 bits (currently this is not significantly faster because multiple function calls are necessary) . |
| get_v4_urandom_native/0 |
Get a v4 UUID (using Wichmann-Hill 1982).Attempt to only use native integers (Erlang limits integers to 27 bits before using bigints) to investigate the speed when using HiPE. |
| get_v5/1 |
Get a v5 UUID.. |
| get_v5/2 |
Get a v5 UUID in a particular namespace.. |
| get_v5_compat/1 |
Get a compatible v5 UUID.Do not use all bits from the checksum so that the UUID matches external implementations. |
| get_v5_compat/2 |
Get a compatible v5 UUID in a particular namespace.Do not use all bits from the checksum so that the UUID matches external implementations. |
| increment/1 |
Increment the clock sequence of v1 UUID state.Call to increment the clock sequence counter after the system clock has been set backwards (see the RFC). |
| is_uuid/1 |
Is the binary a UUID?. |
| is_v1/1 |
Is the binary a v1 UUID?. |
| is_v3/1 |
Is the binary a v3 UUID?. |
| is_v4/1 |
Is the binary a v4 UUID?. |
| is_v5/1 |
Is the binary a v5 UUID?. |
| mac_address/0 |
Provide a usable network interface MAC address.. |
| new/1 |
Create new UUID state for v1 UUID generation.. |
| new/2 |
Create new UUID state for v1 UUID generation using a specific type of timestamp.The timestamp can either be based on erlang's adjustment of time (for only strictly monotonically increasing time values) or the operating system's time without any adjustment (with timestamp_type valueserlang and os, respectively). |
| string_to_uuid/1 |
Convert a string representation to a UUID.. |
| test/0 |
Regression test.. |
| uuid_to_list/1 |
Convert a UUID to a list.. |
| uuid_to_string/1 |
Convert a UUID to a string representation.. |
| uuid_to_string/2 |
Convert a UUID to a string representation based on an option.. |
get_v1_time() -> non_neg_integer()
get_v1_time(Uuid_state::timestamp_type() | state() | uuid()) -> non_neg_integer()
get_v3(Data::binary()) -> uuid()
get_v3(Namespace::dns | url | oid | x500 | binary(), Data::binary() | iolist()) -> uuid()
get_v3_compat(Data::binary()) -> uuid()
get_v3_compat(Namespace::dns | url | oid | x500 | binary(), Data::binary() | iolist()) -> uuid()
get_v4() -> uuid()
get_v4(X1::strong | weak) -> uuid()
get_v4_urandom() -> uuid()
get_v4_urandom_bigint() -> uuid()
random:uniform/1 repeats every 2.78e13 (see B.A. Wichmann and I.D.Hill, in 'An efficient and portable pseudo-random number generator', Journal of Applied Statistics. AS183. 1982, or Byte March 1987) a single random:uniform/1 call can provide a maximum of 45 bits (currently this is not significantly faster because multiple function calls are necessary)
explain the 45 bits of randomness: random:uniform/0 code: B1 = (A1*171) rem 30269, B2 = (A2*172) rem 30307, B3 = (A3*170) rem 30323, put(random_seed, {B1,B2,B3}), R = A1/30269 + A2/30307 + A3/30323, R - trunc(R).
{B1, B2, B3} becomes the next seed value {A1, A2, A3}, so: R = (918999161 * A1 + 917846887 * A2 + 917362583 * A3) / 27817185604309 Whatever the values for A1, A2, and A3, (918999161 * A1 + 917846887 * A2 + 917362583 * A3) can not exceed 27817185604309 (30269 * 30307 * 30323) because of the previous modulus. So, random:uniform/1 is unable to uniformly sample numbers beyond a N of 27817185604309. The bits required to represent 27817185604309: 1> (math:log(27817185604309) / math:log(2)) + 1. 45.6610416965467get_v4_urandom_native() -> uuid()
get_v5(Data::binary()) -> uuid()
get_v5(Namespace::dns | url | oid | x500 | binary(), Data::binary() | iolist()) -> uuid()
get_v5_compat(Data::binary()) -> uuid()
get_v5_compat(Namespace::dns | url | oid | x500 | binary(), Data::binary() | iolist()) -> uuid()
os or warp timestamp_type is used.
is_uuid(Value::any()) -> boolean()
is_v1(Value::any()) -> boolean()
is_v3(Value::any()) -> boolean()
is_v4(Value::any()) -> boolean()
is_v5(Value::any()) -> boolean()
mac_address() -> [non_neg_integer()]
new(Pid::pid()) -> state()
new(Pid::pid(), Options::timestamp_type() | [{timestamp_type, timestamp_type()} | {mac_address, [non_neg_integer()]}]) -> state()
erlang and os, respectively).
If you want erlang's adjustment of time without enforcement of increasing
time values, use the warp timestamp_type value with Erlang >= 18.0.
string_to_uuid(X1::string() | binary()) -> uuid()
test() -> ok
uuid_to_list(Value::uuid()) -> iolist()
uuid_to_string(Value::uuid()) -> string()
uuid_to_string(Value::uuid(), Option::standard | nodash | list_standard | list_nodash | binary_standard | binary_nodash) -> string() | binary()
Generated by EDoc, Apr 12 2015, 17:05:53.