Module: Webhookdb::Crypto
- Defined in:
- lib/webhookdb/crypto.rb
Defined Under Namespace
Classes: Boxed
Class Method Summary collapse
- .bin2hex(s) ⇒ Object
- .cipher ⇒ Object
- .decrypt_value(key, value) ⇒ Boxed
- .encrypt_value(key, value) ⇒ Boxed
- .encryption_key ⇒ Boxed
Class Method Details
.bin2hex(s) ⇒ Object
4 5 6 |
# File 'lib/webhookdb/crypto.rb', line 4 def self.bin2hex(s) return s.unpack1("H*") end |
.cipher ⇒ Object
8 9 10 |
# File 'lib/webhookdb/crypto.rb', line 8 def self.cipher return OpenSSL::Cipher.new("aes-256-cbc") end |
.decrypt_value(key, value) ⇒ Boxed
31 32 33 34 35 36 |
# File 'lib/webhookdb/crypto.rb', line 31 def self.decrypt_value(key, value) cipher = self.cipher.decrypt cipher.key = key.raw dec = cipher.update(value.raw) + cipher.final return Boxed.from_raw(dec) end |