occulto/README.md

48 lines
889 B
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
```
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
2019-07-07 21:44:18 +02:00
```typescript
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
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
2019-07-07 21:44:18 +02:00
```typescript
2019-07-07 21:39:31 +02:00
import { Hash } from 'occulto'
2019-07-07 21:20:42 +02:00
const hash = Hash.digest('something')
2019-07-07 21:44:18 +02:00
const h = Hash.digest('something', Hash.Hashes.MD5)
2019-07-07 21:20:42 +02:00
2019-03-30 20:50:04 +01:00
```