Class: DataMapper::Property::APIKey

Inherits:
String
  • Object
show all
Defined in:
lib/dm-types/api_key.rb

Constant Summary

PADDING =

The amount of random seed data to use to generate tha API Key

256

Class Method Summary collapse

Class Method Details

.generateString

Generates a new API Key.

Returns:

  • (String)

    The new API Key.



22
23
24
25
26
27
# File 'lib/dm-types/api_key.rb', line 22

def self.generate
  sha1 = Digest::SHA1.new

  PADDING.times { sha1 << rand(256).chr }
  return sha1.hexdigest
end