Skip to content

Instantly share code, notes, and snippets.

@oleganza
Created November 19, 2009 15:06
Show Gist options
  • Save oleganza/238810 to your computer and use it in GitHub Desktop.
Save oleganza/238810 to your computer and use it in GitHub Desktop.
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