Created
December 2, 2008 05:28
-
-
Save sporkmonger/31013 to your computer and use it in GitHub Desktop.
This is NOT how to generate valid UUIDs.
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
def rand_hex_3(l) | |
"%0#{l}x" % rand(1 << l*4) | |
end | |
def rand_uuid | |
[8,4,4,4,12].map {|n| rand_hex_3(n)}.join('-') | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment