openresty / openresty/lua-resty-string
lua use resty.aes Encrypted hex result diff from c++ use openssl
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 443
- Forks
- 143
- Avg merge
- 2h 31m
- Merged PRs (30d)
- 1
Description
the same key and the same mesg, but the result is different, why?
lua:
local key = "1"
local mesg = "2"
local aes_256_cbc_sha1x5 = aes:new(key, salt, aes.cipher(256,"cbc"), aes.hash.sha1, 5)
local encrypted = aes_256_cbc_sha1x5:encrypt(mesg)
ngx.say("AES 256 CBC (SHA-1, salted) Encrypted HEX: ", str.to_hex(encrypted))
AES 256 CBC (SHA-1, salted) Encrypted HEX: 619a1da54b6c5113eb335a74296fed54
c++:
int i, nrounds = 5;
unsigned char key[32], iv[32];
i = EVP_BytesToKey(EVP_aes_256_cbc(), EVP_sha1(), NULL, key_data, key_data_len, nrounds, key, iv);
...
hex:1671d15e1905d518201b35064043cb71
to_hex api invoke ngx_hex_dump, it developed by C , same to my own c++ coding, but the result's display is different, Why???
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the resty.aes encrypt entry point and the shown C++ EVP_BytesToKey call, then compare the key, salt, cipher, hash, rounds, and hex output in the examples. Reproduce both results and document a maintainer-confirmed explanation for the difference; no repository file or test is named in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, lua
- Domain
- cryptography, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100