Module: SignedConfig::Crypto

Defined in:
lib/signed_config/crypto.rb

Class Method Summary collapse

Class Method Details

.sign(key, string) ⇒ Object

Return a signature for the string



12
13
14
# File 'lib/signed_config/crypto.rb', line 12

def sign(key, string)
  Base64.encode64(rsa_key(key).sign(OpenSSL::Digest::SHA1.new, string))
end

.verify(key, signature, string) ⇒ Object

Verify the string and signature



17
18
19
# File 'lib/signed_config/crypto.rb', line 17

def verify(key, signature, string)
  rsa_key(key).verify(OpenSSL::Digest::SHA1.new, Base64.decode64(signature), string)
end