lib/aes/aes.rb in aes-0.5.0 vs lib/aes/aes.rb in aes-0.5.1
- old
+ new
@@ -9,11 +9,11 @@
::AES::AES.new(key, opts).decrypt(cipher_text)
end
# Generates a random key of the specified length in bits
# Default format is :plain
def key(length=256,format=:plain)
- key = ::AES::AES.new("").random_key(256)
+ key = ::AES::AES.new("").random_key(length)
case format
when :base_64
Base64.encode64(key).chomp
else
key
@@ -146,10 +146,10 @@
@options[:padding] = @options[:padding] ? 1 : 0
end
# Create a new cipher using the cipher type specified
def _setup(action)
- @cipher ||= OpenSSL::Cipher::Cipher.new(@options[:cipher])
+ @cipher ||= OpenSSL::Cipher.new(@options[:cipher])
# Toggles encryption mode
@cipher.send(action)
@cipher.padding = @options[:padding]
@cipher.key = @key.unpack('a2'*32).map{|x| x.hex}.pack('c'*32)
end