Api key (or any kind of key) generator
1 2 class KeyGenerator 3 require "digest/sha1" 4 def self.generate(length = 10) 5 Digest::SHA1.hexdigest(Time.now.to_s + rand(12341234).to_s)[1..length] 6 end 7 end
DZone Snippets > leethal > key
13502 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
August Lilleaas http://august.lilleaas.net
1 2 class KeyGenerator 3 require "digest/sha1" 4 def self.generate(length = 10) 5 Digest::SHA1.hexdigest(Time.now.to_s + rand(12341234).to_s)[1..length] 6 end 7 end