lib/rmega/crypto/aes.rb in rmega-0.0.6 vs lib/rmega/crypto/aes.rb in rmega-0.1.0
- old
+ new
@@ -1,27 +1,29 @@
+require 'openssl'
+
module Rmega
module Crypto
module Aes
extend self
def packing
'l>*'
end
def cipher
- @cipher ||= OpenSSL::Cipher::AES.new 128, :CBC
+ @cipher ||= OpenSSL::Cipher::AES.new(128, :CBC)
end
- def encrypt key, data
+ def encrypt(key, data)
cipher.reset
cipher.padding = 0
cipher.encrypt
cipher.key = key.pack(packing)
result = cipher.update data.pack(packing)
result.unpack packing
end
- def decrypt key, data
+ def decrypt(key, data)
cipher.reset
cipher.padding = 0
cipher.decrypt
cipher.key = key.pack packing
result = cipher.update data.pack(packing)