Class: Urg::SecureData
- Inherits:
-
Object
- Object
- Urg::SecureData
- Defined in:
- lib/secure_data.rb
Class Method Summary collapse
Class Method Details
.decrypt(cyphertext, iv:, key:) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/secure_data.rb', line 18 def self.decrypt(cyphertext, iv:, key:) cipher.decrypt cipher.key = Base64.strict_decode64(key) cipher.iv = Base64.strict_decode64(iv) cipher.update(Base64.strict_decode64(cyphertext)) + cipher.final end |
.encrypt(plaintext) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/secure_data.rb', line 5 def self.encrypt(plaintext) cipher.encrypt key = cipher.random_key iv = cipher.random_iv cyphertext = cipher.update(plaintext) + cipher.final { cyphertext: Base64.strict_encode64(cyphertext), key: Base64.strict_encode64(key), iv: Base64.strict_encode64(iv) } end |