Skip to content

Instantly share code, notes, and snippets.

@oleganza
Created July 13, 2009 14:05
Show Gist options
  • Save oleganza/146160 to your computer and use it in GitHub Desktop.
Save oleganza/146160 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
Array.new(21).map{ Alphabet[rand(2**6),1] }.join
end
end
n = 5
n.times { p Id64.random }
n.times { p rand(2**132).to_s(32) }
n.times { p rand(2**132).to_s(16) }
n.times { p rand(2**132).to_s(8) }
n.times { p rand(2**132).to_s(4) }
__END__
"U9BpIVscWd1R25dqQEd7h"
"eQhTjC8xisb_N2pqN9V3-"
"KICoPHqyWon8qm1aFKNcp"
"_RSRF57_Cw-cBljn3sHXG"
"VBKz9QY7tQr8RVXSQOaL4"
"10i61n2og8kn70p3900nr0j0gva"
"2vk8s07igpn8upptqg5shqd7q81"
"496albv703ook7sq7d46uida3t"
"1p8bnibffc9kg7of446h0tldf7v"
"3iek89ai6vf8setkptp3aaucl76"
"ab389c1bd03e5553d022cee688c7a8b55"
"436708621adc16fed15b27060eaf2c062"
"e2549c94f106e8e94dc2ad777fe82274f"
"e2b6bd4237512b3c4a4db486d62c5ef6a"
"53e2e2962a01150d964eba3afa4821909"
"140642553551731042244414627704163130125165"
"65562542541166621734652301420050620016640664"
"51263360255260553341620410441633660332066333"
"3340701002023451055537141600424356122271061"
"41000530766214374221160211764665427135246377"
"132021002232301012023222132332330200113221300122222133331203111333"
"103312131311102333132220121312102303003113211330212122102123202002"
"303002031230231100113320302231100123231100301023303021233321303301"
"33010133030111331020302231102231002301132020132233233313220003323"
"102302212212123100102212300100013301110332201000020233213010030000"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment