Your hex string is actually different from your ascii string.
irb(main):003:0> "welcome1welcome1".unpack("H*")
=> ["77656c636f6d653177656c636f6d6531"]
77656c636f6d653177656c636f6d6531
77656c636f6d653177656c636f6d653112
You have 12 added to your hex string, which is an odd control char, so likely just a typo or error in copying.
Cheers,
Ben
-----Original Message-----
From: yk...@gmail.com
Sent: Monday, August 4, 2014 12:26pm
To: openresty-en@googlegroups.com
Subject: [openresty-en] how to decrypt with lua-resty string token encrypted with openssl
Hi guys,
key1 is hex of key2.
"sampletoken" is decrypted with openssl.
How to decrypt it with lua resty string ?
key1="77656c636f6d653177656c636f6d653112"
key2="welcome1welcome1"
echo "sampletoken" | openssl enc -nosalt -aes-128-ecb -a -K $key1
I tried this one - ecrypted_token = "avIc3u8Efb6cqdwn2VGntw==";
local aes_128_ecb_md5 = aes:new("welcome1welcome1",nil, aes.cipher(128,"ecb"))
newstr = ngx.decode_base64(ecrypted_token)
plain_token = aes_128_ecb_md5:decrypt(newstr)
Thanks,
Yuri
--
.