Class: SharedSecretAuthentication::Generator
- Inherits:
-
Object
- Object
- SharedSecretAuthentication::Generator
- Defined in:
- lib/shared-secret-authentication/generator.rb
Class Method Summary collapse
- .shared_secret(length = 10) ⇒ Object (also: api_key)
Class Method Details
.shared_secret(length = 10) ⇒ Object Also known as: api_key
4 5 6 7 |
# File 'lib/shared-secret-authentication/generator.rb', line 4 def self.shared_secret(length = 10) raise ArgumentError.new 'a key has a maximum of 64 numbers and letters' if length > 64 Digest::SHA2.hexdigest(Time.now.to_s + rand(123456789).to_s)[0..length - 1] end |