Class: PrefixApiKey::Generate
- Inherits:
-
Object
- Object
- PrefixApiKey::Generate
- Defined in:
- lib/prefix_api_key/generate.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.call(prefix: "prefix") ⇒ Object
6 7 8 |
# File 'lib/prefix_api_key/generate.rb', line 6 def self.call(prefix: "prefix") new.call(prefix: prefix) end |
Instance Method Details
#call(prefix: "prefix") ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/prefix_api_key/generate.rb', line 10 def call(prefix: "prefix") short_token = Base64.strict_encode64(prefix + salt_short + password_short)[0..6] long_token = Base64.strict_encode64(salt_long + password_long + prefix) long_token_hash = ::Digest::SHA2.hexdigest(long_token) token = "#{prefix}_#{short_token}_#{long_token}" { short_token: short_token, long_token: long_token, long_token_hash: long_token_hash, token: token, prefix: prefix } end |