https://github.com/morajabi/tiny-crypto-node
🔑 Modern Encrypt / decrypt strings (access tokens, secret names, etc) with a key for node
https://github.com/morajabi/tiny-crypto-node
aes-256 aes-encryption crypto encryption nodejs security
Last synced: 2 months ago
JSON representation
🔑 Modern Encrypt / decrypt strings (access tokens, secret names, etc) with a key for node
- Host: GitHub
- URL: https://github.com/morajabi/tiny-crypto-node
- Owner: morajabi
- License: mit
- Created: 2018-08-20T09:00:15.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-08-21T09:32:38.000Z (almost 8 years ago)
- Last Synced: 2025-04-02T03:15:49.470Z (over 1 year ago)
- Topics: aes-256, aes-encryption, crypto, encryption, nodejs, security
- Language: JavaScript
- Homepage:
- Size: 19.5 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Tiny Crypto
Simpler (but secure) crypto utility alternative to the native crypto module shipped with Node.
Tiny Crypto is only for strings like access tokens, secure names, secure Ids, etc and not meant for passwords! (passwords shouldn't be decryptable therefore use [bcrypt](https://www.npmjs.com/package/bcrypt))
## Install
```bash
yarn add tiny-crypto # or npm install tiny-crypto
```
## Use
Keep in mind this is node-only! Here's how you can use it:
```js
// Import!
import TinyCrypto from 'tiny-crypto'
// Init!
const tinyCrypto = new TinyCrypto('secretk3y!') // Ideally from an environment variable
// Use!
const encryptedString = tinyCrypto.encrypt('bacon')
const decryptedString = tinyCrypto.decrypt(encryptedString)
console.log(encryptedString) // 5590fd6409be2494de0226f5d7
console.log(decryptedString) // bacon
```
## Flow Type
I ship a flow type version too, feel free to send a PR if there's any issues. I'm here.
## PRs welcome!
## Idea
- Base code taken from [Cryptr](https://github.com/MauriceButler/cryptr)
## MIT
- Modernized by [Mo Rajabifard](https://twitter.com/morajabi)