occulto/README.md

64 lines
1.3 KiB
Markdown
Raw Normal View History

2019-03-30 20:50:04 +01:00
# occulto 🔒
2019-07-07 21:20:42 +02:00
High level wrapper around [forge](https://github.com/digitalbazaar/forge).
Supports Hashes, Symmetric AES & ChaCha20 ciphers and Asymmetric RSA.
2019-03-30 20:50:04 +01:00
**Typescript typings included**
## Quickstart 🚀
###### Install
```
2019-07-07 21:20:42 +02:00
npm i node-forge occulto
2019-03-30 20:50:04 +01:00
```
```javascript
// Whatever import you prefer
// const { RSA } = require('occulto')
import { RSA } from 'occulto'
const pair = await RSA.gen()
const encrypted = RSA.encrypt('some string', 'myPass')
const decrypted = RSA.decrypt(encrypted, 'myPass')
```
2019-07-07 21:39:31 +02:00
[**📒 DOCS HERE 📒**](https://cupcakearmy.github.io/occulto/index.html)
2019-03-30 20:50:04 +01:00
2019-07-07 21:39:31 +02:00
### Examples
2019-03-30 20:50:04 +01:00
2019-07-07 21:39:31 +02:00
## RSA
2019-03-30 20:50:04 +01:00
```javascript
2019-03-30 21:01:12 +01:00
const pair = await RSA.gen()
const encrypted = RSA.encrypt('some text', pair.pub)
const decrypted = RSA.decrypt(encrypted, pair.prv)
2019-03-30 20:50:04 +01:00
```
2019-07-07 21:20:42 +02:00
## Symmetric
2019-03-30 20:50:04 +01:00
```javascript
2019-07-07 21:39:31 +02:00
// Whatever import you prefer
// const { Symmetric } = require('occulto')
import { Symmetric } from 'occulto'
2019-03-30 20:50:04 +01:00
2019-07-07 21:39:31 +02:00
const encrypted = Symmetric.encrypt('some string' , 'myPass', Symmetric.Ciphers.AES_128_GCM)
const decrypted = Symmetric.decrypt(encrypted, 'myPadd')
2019-03-30 20:50:04 +01:00
```
2019-07-07 21:20:42 +02:00
## Hash
2019-03-30 20:50:04 +01:00
```javascript
2019-07-07 21:39:31 +02:00
// Whatever import you prefer
// const { Hash } = require('occulto')
import { Hash } from 'occulto'
2019-07-07 21:20:42 +02:00
const hash = Hash.digest('something')
const h = Hash.digest('something', Hashes.MD5)
2019-03-30 20:50:04 +01:00
```