Skip to content

Instantly share code, notes, and snippets.

@yorzi
Created March 29, 2011 03:03
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yorzi/891741 to your computer and use it in GitHub Desktop.
Save yorzi/891741 to your computer and use it in GitHub Desktop.
api key(or any other kind of key) generator via ruby.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment