3 class UniqueTokenGenerator
4 def initialize(length=10)
8 # this should probably be rewritten as a class method
11 while token.length < @length
14 seed << ( i = Kernel.rand(62)
15 i += ((i < 10) ? 48 : ((i < 36) ? 55 : 61 )) ).chr
17 token << Digest::MD5.hexdigest( seed )
19 token.slice( 0..@length )
24 # puts UniqueTokenGenerator.new(300).token