occulto/README.md

54 lines
1.3 KiB
Markdown
Raw Normal View History

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