Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/melkir/crypto
Simple aes-256-gcm encryption and decryption module for NodeJS.
https://github.com/melkir/crypto
Last synced: 2 days ago
JSON representation
Simple aes-256-gcm encryption and decryption module for NodeJS.
- Host: GitHub
- URL: https://github.com/melkir/crypto
- Owner: melkir
- License: mit
- Created: 2022-07-10T18:08:18.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-25T14:28:43.000Z (2 months ago)
- Last Synced: 2024-10-25T16:25:24.987Z (2 months ago)
- Language: TypeScript
- Size: 279 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Crypto
> Simple aes-256-gcm encryption and decryption module for NodeJS.
## Install
```sh
npm install @melkir/crypto
```## Usage
```js
import { randomBytes } from "node:crypto";
import { decrypt, encrypt } from "@melkir/crypto";// The key must contain exactly 32 characters.
// The following instruction generates one randomly which you can then save in your environment variables.
const key = randomBytes(16).toString("hex");const message = "Shh its a seekrit";
const encrypted = encrypt(message, key);
// You can now send your encrypted message to anyone without worrying about it being intercepted.
// The person who receives your message will then be able to decipher the content in the following way.
const decrypted = decrypt(encrypted, key);
```## Credits
Thanks [@vlucas](https://github.com/vlucas) for the [gist](https://gist.github.com/vlucas/2bd40f62d20c1d49237a109d491974eb?permalink_comment_id=3771967#gistcomment-3771967).