From ad76738cd8817fecf1afcb558edb0d9261c14709 Mon Sep 17 00:00:00 2001 From: ntloi Date: Fri, 2 Oct 2020 17:57:04 +0700 Subject: [PATCH] Change hard code 32 key len by cipher key len return by OpenSSL. Fix break on Ruby 2.5.3 --- lib/aes/aes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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