aes
aes copied to clipboard
Error in Ruby 2.5.3, set cipher.key: Exception “key must be 16 bytes"
def _setup(action)
@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
When i upgrade to ruby 2.5.3, OpenSSL::Cipher required key length = 16 when @options[:cipher] = 'AES-128-CBC'
@key.unpack('a2'*32).map{|x| x.hex}.pack('c'*32) => "o\xA8\xBB\a#'\xF8\xD0\xE4\v\x85\xFA\xD9\x05\x10\xF9\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
we just need the first 16 bytes.