Skip to content

Instantly share code, notes, and snippets.

@yorzi
Created March 29, 2011 03:03
Show Gist options
  • 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