Class: RedisRpc::Base64Aes
- Inherits:
-
Object
- Object
- RedisRpc::Base64Aes
- Defined in:
- lib/redis_rpc/parser.rb
Instance Method Summary collapse
- #decrypt(encrypted) ⇒ Object
- #encrypt(data) ⇒ Object
-
#initialize(key) ⇒ Base64Aes
constructor
A new instance of Base64Aes.
Constructor Details
#initialize(key) ⇒ Base64Aes
Returns a new instance of Base64Aes.
28 29 30 31 32 |
# File 'lib/redis_rpc/parser.rb', line 28 def initialize(key) @key = key @cipher = OpenSSL::Cipher::AES.new(128, :CBC).encrypt @decipher = OpenSSL::Cipher::AES.new(128, :CBC).decrypt end |
Instance Method Details
#decrypt(encrypted) ⇒ Object
37 38 39 40 |
# File 'lib/redis_rpc/parser.rb', line 37 def decrypt(encrypted) @decipher.key = @key @decipher.update(decode64(encrypted)) + @decipher.final end |
#encrypt(data) ⇒ Object
33 34 35 36 |
# File 'lib/redis_rpc/parser.rb', line 33 def encrypt(data) @cipher.key = @key encode64(@cipher.update(data) + @cipher.final) end |