Last active
February 17, 2016 14:51
-
-
Save eiri/417af4243fb00c73ecc4 to your computer and use it in GitHub Desktop.
Generate random unique keys with erlang's reference
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
make_random_ref_key() -> | |
<<X:264/big-unsigned-integer>> = term_to_binary(make_ref()), | |
[Key] = io_lib:format("~66.16.0b", [X]), | |
{ok, Key}. | |
make_random_md5_key() -> | |
<<X:128/big-unsigned-integer>> = crypto:hash(md5, term_to_binary(make_ref())), | |
[Key] = io_lib:format("~32.16.0b", [X]), | |
{ok, Key}. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment