Module: BasicSSL
- Defined in:
- lib/basic_ssl.rb
Class Method Summary collapse
-
.decrypt(key, string) ⇒ Object
Return the raw string after decryption & decoding.
-
.encrypt(key, string) ⇒ Object
Returns an Base64 encoded string with encryption.
-
.sign(key, string) ⇒ Object
Return a signature for the string.
-
.verify(key, signature, string) ⇒ Object
Verify the string and signature.
Class Method Details
.decrypt(key, string) ⇒ Object
Return the raw string after decryption & decoding
14 15 16 |
# File 'lib/basic_ssl.rb', line 14 def decrypt(key, string) rsa_key(key).private_decrypt(Base64.decode64(string)) end |
.encrypt(key, string) ⇒ Object
Returns an Base64 encoded string with encryption
9 10 11 |
# File 'lib/basic_ssl.rb', line 9 def encrypt(key, string) Base64.encode64(rsa_key(key).public_encrypt(string)) end |
.sign(key, string) ⇒ Object
Return a signature for the string
19 20 21 |
# File 'lib/basic_ssl.rb', line 19 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
24 25 26 |
# File 'lib/basic_ssl.rb', line 24 def verify(key, signature, string) rsa_key(key).verify(OpenSSL::Digest::SHA1.new, Base64.decode64(signature), string) end |