Never been to DZone Snippets before?

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

Api key (or any kind of key) generator (See related posts)

Generates a random key for API neatness.

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

You need to create an account or log in to post comments to this site.


Click here to browse all 4858 code snippets

Related Posts