Api key (or any kind of key) generator
class KeyGenerator require "digest/sha1" def self.generate(length = 10) Digest::SHA1.hexdigest(Time.now.to_s + rand(12341234).to_s)[1..length] end end
DZone Snippets > leethal > key
11382 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
class KeyGenerator require "digest/sha1" def self.generate(length = 10) Digest::SHA1.hexdigest(Time.now.to_s + rand(12341234).to_s)[1..length] end end