aes icon indicating copy to clipboard operation
aes copied to clipboard

Error in Ruby 2.5.3, set cipher.key: Exception “key must be 16 bytes"

Open ntloi95 opened this issue 4 years ago • 1 comments

   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'

ntloi95 avatar Oct 02 '20 10:10 ntloi95

@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.

ntloi95 avatar Oct 02 '20 10:10 ntloi95