From: John Mettraux Date: 2008-12-30T10:07:26+09:00 Subject: Re: Options to generate small, kind of unique, human-readable tokens (like "V0cM9tnV") ? On Mon, Dec 29, 2008 at 6:44 PM, Thibaut Barrère wrote: > Hi, > > I'm pretty sure there is a number of options to achieve this, so I'm > asking here. I often need to generate small unique tokens (like for > invitation codes or unimportant authentication token). > > In the past I've been using Digest::SHA1.hexdigest(some string) which > gives us something like "d2b7882fa08bb6de8dca62f16298683bfe4f0738". > It's not very user friendly though, and definitely not small. Hi Thibaut, I have this rufus-mnemo that turns integers into "user friendly" strings. http://github.com/jmettraux/rufus-mnemo After a "sudo gem install rufus-mnemo" you can do things like ---8<--- require 'rubygems' require 'rufus/mnemo' s = Rufus::Mnemo::from_integer(125704) puts s # => 'karasu' --->8--- Not exactly what you want, but could be funny. It's using a restricted syllabary (the Japanese one) to turn integers into words (and back). As twittered, it has the potential to generate insulting words. The generated syllables sequences are quite easy to the latin ears though. Best regards, meilleurs voeux pour 2009, -- John Mettraux - http://jmettraux.wordpress.com