From caaec8b04815f2b7e2de2ec717f33519a4170083 Mon Sep 17 00:00:00 2001 From: cupcakearmy Date: Sun, 7 Jul 2019 21:20:42 +0200 Subject: [PATCH] docs --- README.md | 49 ++++++++++++++++++++++++++++++++++++------------- package.json | 12 +++++++----- 2 files changed, 43 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index a8ee1cf..0cc4e74 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # occulto 🔒 -High leven wrapper around [forge](https://github.com/digitalbazaar/forge). +High level wrapper around [forge](https://github.com/digitalbazaar/forge). + +Supports Hashes, Symmetric AES & ChaCha20 ciphers and Asymmetric RSA. **Typescript typings included** @@ -9,7 +11,7 @@ High leven wrapper around [forge](https://github.com/digitalbazaar/forge). ###### Install ``` -npm i occulto +npm i node-forge occulto ``` ```javascript @@ -62,36 +64,57 @@ const encrypted = RSA.encrypt('some text', pair.pub) const decrypted = RSA.decrypt(encrypted, pair.prv) ``` -## AES +## Symmetric -### `AES.Ciphers` +### `Symmetric.Ciphers` Available ciphers +- `Ciphers.ChaCha20` - `Ciphers.AES_256_GCM` - `Ciphers.AES_192_GCM` - `Ciphers.AES_128_GCM` +- `Ciphers.AES_256_CTR` +- `Ciphers.AES_192_CTR` +- `Ciphers.AES_128_CTR` -#### `AES.encrypt(data: string, key: string, type: Ciphers = Ciphers.AES_256_GCM)` +#### `Symmetric.encrypt(data: string, key: string, type: Ciphers = Ciphers.AES_256_GCM)` Encrypts a string. -Defaults to `Ciphers.AES_256_GCM` +Defaults to `Ciphers.AES_256_CTR` ###### Examples ```javascript -const encrypted = AES.encrypt('some string' , 'myPass') +const encrypted = Symmetric.encrypt('some string' , 'myPass') -const e = AES.encrypt('some string' , 'myPass', Ciphers.AES_128_GCM) +const e = Symmetric.encrypt('some string' , 'myPass', Ciphers.AES_128_GCM) ``` -#### `RSA.decrypt(e: string, key: string)` +## Hash -Decrypt data encrypted by `AES.encrypt()` +### `Hash.Hashes` -###### Example +Available hashes + +- `Hashes.MD5` +- `Hashes.SHA1_1` +- `Hashes.SHA1_256` +- `Hashes.SHA1_512` +- `Hashes.SHA3_256` +- `Hashes.SHA3_384` +- `Hashes.SHA3_512` + +#### `Hash.digest(s: string, type: Hashes = Hashes.SHA3_256)` + +Calculates the hash of a string. +Defaults to `Hashes.SHA3_256` + +###### Examples ```javascript -const encrypted = AES.encrypt('some string' , 'myPass') -const decrypted = AES.decrypt(encrypted , 'myPass') +const hash = Hash.digest('something') + +const h = Hash.digest('something', Hashes.MD5) + ``` diff --git a/package.json b/package.json index a4639e2..a9d6eb9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "occulto", - "version": "1.0.6", + "version": "1.0.7", "description": "crypt utility", "main": "./lib/index.js", "types": "./lib/index.d.ts", @@ -9,6 +9,7 @@ "url": "https://github.com/CupCakeArmy/occulto" }, "scripts": { + "docs": "typedoc --out ./docs ./src", "build": "tsc", "dev": "tsnd --respawn --no-notify src/index.ts", "test": "npm run build && mocha", @@ -24,11 +25,12 @@ "author": "Niccolo Borgioli", "license": "MIT", "devDependencies": { - "@types/node": "^11.13.1", - "@types/node-forge": "^0.8.2", - "mocha": "^6.1.1", + "@types/node": "11.x", + "@types/node-forge": "0.8.x", + "mocha": "6.x", "ts-node-dev": "^1.0.0-pre.32", - "typescript": "^3.4.2" + "typedoc": "^0.14.2", + "typescript": "3.5.x" }, "dependencies": {} }