https://github.com/venipa/encryption.js
Encrypt/Decrypt tokens send from server/client, only decryptable from server. supports objects
https://github.com/venipa/encryption.js
aes encrypted-data encryption node secret web
Last synced: 7 months ago
JSON representation
Encrypt/Decrypt tokens send from server/client, only decryptable from server. supports objects
- Host: GitHub
- URL: https://github.com/venipa/encryption.js
- Owner: Venipa
- Created: 2022-12-12T22:39:45.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-11-09T23:26:02.000Z (8 months ago)
- Last Synced: 2024-11-09T23:28:02.244Z (8 months ago)
- Topics: aes, encrypted-data, encryption, node, secret, web
- Language: TypeScript
- Homepage:
- Size: 130 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

[](https://www.npmjs.com/package/encryption.js)


## Encryption Utility
---
simple encryption class for node or browser (as of v1.0.0) apps, allows setting app secret & set purpose of encryption, inspired from adonis encryption feature## Quick Start
```ts
// Create Static Encryption constant
// src/lib/Encryption.ts
import { default as AppEncryption } from 'encryption.js';
const Encryption = new AppEncryption({ secret: process.env.APP_SECRET })
export default Encryption;// usage
// src/app.ts or any other ts to useimport Encryption from './lib/Encryption';
// encrypt payload with a expiry date & purpose which acts like a salt, decrypting will require the purpose to return the encrypted object, otherwise null
const token = Encryption.encrypt({ userId: "" }, Date.now() + 1000 * 60 * 60, "emailVerify");// some user <> server things
// server handles payload
const payload = Encryption.decrypt(token, "emailVerify");
```