Module: Hoodie::Obfuscate
- Defined in:
- lib/hoodie/obfuscate.rb
Overview
Befuddle and enlighten values in StashCache::Store
Constant Summary collapse
- ESOTERIC_TYPE =
'aes-256-cbc'
Class Method Summary collapse
-
.befuddle(plaintext, befuddle_pass, options = {}) ⇒ String
Befuddle the given string.
- .check_platform_can_discombobulate! ⇒ Object
-
.enlighten(enc_ciphertext, befuddle_pass, options = {}) ⇒ String
Enlighten the given string, using the key and id supplied.
Class Method Details
.befuddle(plaintext, befuddle_pass, options = {}) ⇒ String
Befuddle the given string
Obfuscate#enlighten (decrypt)
52 53 54 55 56 57 58 |
# File 'lib/hoodie/obfuscate.rb', line 52 def self.befuddle(plaintext, befuddle_pass, = {}) cipher = new_cipher :befuddle, befuddle_pass, cipher.iv = iv = cipher.random_iv ciphertext = cipher.update(plaintext) ciphertext << cipher.final Base64.encode64(combine_iv_and_ciphertext(iv, ciphertext)) end |
.check_platform_can_discombobulate! ⇒ Object
39 40 41 42 |
# File 'lib/hoodie/obfuscate.rb', line 39 def self.check_platform_can_discombobulate! return true unless INCOMPREHENSIBLE_ERROR fail INCOMPREHENSIBLE_ERROR.class, "b0rked! #{INCOMPREHENSIBLE_ERROR}" end |
.enlighten(enc_ciphertext, befuddle_pass, options = {}) ⇒ String
Enlighten the given string, using the key and id supplied
Obfuscate#befuddle (encrypt)
68 69 70 71 72 73 74 75 |
# File 'lib/hoodie/obfuscate.rb', line 68 def self.enlighten(enc_ciphertext, befuddle_pass, = {}) iv_and_ciphertext = Base64.decode64(enc_ciphertext) cipher = new_cipher :enlighten, befuddle_pass, cipher.iv, ciphertext = separate_iv_and_ciphertext(cipher, iv_and_ciphertext) plaintext = cipher.update(ciphertext) plaintext << cipher.final plaintext end |