occulto/README.md

58 lines
1.3 KiB
Markdown
Raw Normal View History

2019-03-30 20:50:04 +01:00
# occulto 🔒
2019-07-10 10:35:00 +02:00
High level wrapper around the [node native crypto API](https://nodejs.org/api/crypto.html).
2019-07-07 21:20:42 +02:00
2019-07-10 10:35:00 +02:00
**No Deps & Typescript typings included**
2019-03-30 20:50:04 +01:00
2019-07-10 10:35:00 +02:00
Supports Hashes, Symmetric AES & ChaCha20 ciphers and Asymmetric RSA.
2019-03-30 20:50:04 +01:00
2019-07-07 21:47:57 +02:00
[**📒 DOCS HERE 📒**](https://cupcakearmy.github.io/occulto/index.html)
2019-03-30 20:50:04 +01:00
## Quickstart 🚀
2019-07-10 10:35:00 +02:00
###### Requirements
- Node >= 11 required (ChaCha20)
2019-03-30 20:50:04 +01:00
###### Install
```
2019-07-10 10:35:42 +02:00
npm i occulto
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:47:57 +02:00
## [RSA](https://cupcakearmy.github.io/occulto/modules/_rsa_.html)
2019-03-30 20:50:04 +01:00
2019-07-07 21:44:18 +02:00
```typescript
2019-07-07 21:48:49 +02:00
import { RSA } from 'occulto'
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:47:57 +02:00
## [Symmetric](https://cupcakearmy.github.io/occulto/modules/_symmetric_.html)
[Available Ciphers](https://cupcakearmy.github.io/occulto/enums/_symmetric_.ciphers.html)
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:47:57 +02:00
## [Hash](https://cupcakearmy.github.io/occulto/modules/_hash_.html)
2019-07-07 21:46:09 +02:00
[Available hashes](https://cupcakearmy.github.io/occulto/enums/_hash_.hashes.html)
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
```