openresty / openresty/encrypted-session-nginx-module

is there any nodejs equivalent implementation?

Open
#30 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
203
Forks
50
Avg merge
1h 25m
Merged PRs (30d)
2

Description

ngx_encrypted_session will plant an expiration time this part is hard. I don't know how to implement it in nodejs. I try to use this snippet to decrypt the string encrypted by encrypted-session-nginx-module, the output is a partial success:

>82^��/H�����j�EG��ɭ���tޡ�楠","permission":128,"username":"11111111","id":1}}c@9}

the nodejs decrypt snippet

import crypto from "crypto";

const ENC_KEY = "xxxxxxxx"; // set random encryption key
const IV = "xxxxxxx"; // set random initialisation vector
// ENC_KEY and IV can be generated as crypto.randomBytes(32).toString('hex');

// const phrase = "who let the dogs out";

const encrypt = (val: string) => {
  let cipher = crypto.createCipheriv("aes-256-cbc", ENC_KEY, IV);
  let encrypted = cipher.update(val, "utf8", "base64");
  encrypted += cipher.final("base64");
  return encrypted;
};

const decrypt = (encrypted: string) => {
  let decipher = crypto.createDecipheriv("aes-256-cbc", ENC_KEY, IV);
  let decrypted = decipher.update(encrypted, "base64", "utf8");
  return decrypted + decipher.final("utf8");
};

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

The issue concerns encrypted-session-nginx-module and a Node.js crypto snippet; start by comparing the module's encrypted session format and expiration behavior with the snippet. Done means a Node.js-compatible approach can decrypt the module's output and handle the expiration semantics consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, node.js, typescript
Domain
cryptography, security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.