openresty / openresty/lua-resty-string

how to implement aes-128-ecb encryption with php or golang

Open
#95 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lua
Stars
443
Forks
143
Avg merge
2h 31m
Merged PRs (30d)
1

Description

here is the lua code

local aes = require 'resty.aes'

local cipher = aes:new('0123456789123456', nil, aes.cipher(128, 'ecb'))

print(ngx.encode_base64(cipher:encrypt('foobar')))

the output should be rTeNAHEZtzsyn1dDAujGgQ==

blow is my php code

var_dump(base64_encode(openssl_encrypt('foobar', 'aes-128-ecb', '0123456789123456', OPENSSL_RAW_DATA)));

the output should be AIIiZT3RO/bkseLE0Mcopg==

how can i get the lua result with php code. pls help me, thanks.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the shown resty.aes configuration with the PHP openssl_encrypt call, including the AES mode, key, padding, and base64 handling. Reproduce both outputs and determine whether the differing ciphertext is caused by mismatched options; done means documenting the equivalent configuration or the remaining incompatibility.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua, php
Domain
cryptography
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.