Class: Walletone::Signer

Inherits:
Object
  • Object
show all
Defined in:
lib/walletone/signer.rb

Constant Summary collapse

SIGN_HASH_TYPES =
[:md5, :sha1]
DEFAULT_HASH_TYPE =
:md5
WMI_SIGNATURE =
'WMI_SIGNATURE'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.sign(content, hash_type) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/walletone/signer.rb', line 15

def self.sign(content, hash_type)
  case hash_type
  when :md5
    Digest::MD5.base64digest content
  when :sha1
    Digest::SHA1.base64digest content
  else
    raise ArgumentError, hash_type
  end
end

Instance Method Details

#signature(secret_key, hash_type = DEFAULT_HASH_TYPE) ⇒ Object



26
27
28
# File 'lib/walletone/signer.rb', line 26

def signature secret_key, hash_type=DEFAULT_HASH_TYPE
  self.class.sign fields_as_string( secret_key ), hash_type
end