Created
November 19, 2009 15:06
-
-
Save oleganza/238810 to your computer and use it in GitHub Desktop.
This file contains 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
module Id64 extend self | |
Alphabet = "0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM_-" | |
(Alphabet.size == 64) or raise "Alphabet should have 64 characters!" | |
def random(length = 22) | |
Array.new(length).map{ Alphabet[rand(2**6),1] }.join # 64**22 == 2**132 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment