diff --git a/lib/aes/aes.rb b/lib/aes/aes.rb index 5235ad4..3abbc2d 100644 --- a/lib/aes/aes.rb +++ b/lib/aes/aes.rb @@ -152,7 +152,7 @@ def _setup(action) # Toggles encryption mode @cipher.send(action) @cipher.padding = @options[:padding] - @cipher.key = @key.unpack('a2'*32).map{|x| x.hex}.pack('c'*32) + @cipher.key = @key.unpack('a2'*@cipher.key_len).map{|x| x.hex}.pack('c'*@cipher.key_len) end end end