This commit is contained in:
cupcakearmy 2019-07-07 21:20:42 +02:00
parent 248c053157
commit caaec8b048
2 changed files with 43 additions and 18 deletions

View File

@ -1,6 +1,8 @@
# occulto 🔒 # 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** **Typescript typings included**
@ -9,7 +11,7 @@ High leven wrapper around [forge](https://github.com/digitalbazaar/forge).
###### Install ###### Install
``` ```
npm i occulto npm i node-forge occulto
``` ```
```javascript ```javascript
@ -62,36 +64,57 @@ const encrypted = RSA.encrypt('some text', pair.pub)
const decrypted = RSA.decrypt(encrypted, pair.prv) const decrypted = RSA.decrypt(encrypted, pair.prv)
``` ```
## AES ## Symmetric
### `AES.Ciphers` ### `Symmetric.Ciphers`
Available ciphers Available ciphers
- `Ciphers.ChaCha20`
- `Ciphers.AES_256_GCM` - `Ciphers.AES_256_GCM`
- `Ciphers.AES_192_GCM` - `Ciphers.AES_192_GCM`
- `Ciphers.AES_128_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. Encrypts a string.
Defaults to `Ciphers.AES_256_GCM` Defaults to `Ciphers.AES_256_CTR`
###### Examples ###### Examples
```javascript ```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 ```javascript
const encrypted = AES.encrypt('some string' , 'myPass') const hash = Hash.digest('something')
const decrypted = AES.decrypt(encrypted , 'myPass')
const h = Hash.digest('something', Hashes.MD5)
``` ```

View File

@ -1,6 +1,6 @@
{ {
"name": "occulto", "name": "occulto",
"version": "1.0.6", "version": "1.0.7",
"description": "crypt utility", "description": "crypt utility",
"main": "./lib/index.js", "main": "./lib/index.js",
"types": "./lib/index.d.ts", "types": "./lib/index.d.ts",
@ -9,6 +9,7 @@
"url": "https://github.com/CupCakeArmy/occulto" "url": "https://github.com/CupCakeArmy/occulto"
}, },
"scripts": { "scripts": {
"docs": "typedoc --out ./docs ./src",
"build": "tsc", "build": "tsc",
"dev": "tsnd --respawn --no-notify src/index.ts", "dev": "tsnd --respawn --no-notify src/index.ts",
"test": "npm run build && mocha", "test": "npm run build && mocha",
@ -24,11 +25,12 @@
"author": "Niccolo Borgioli", "author": "Niccolo Borgioli",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@types/node": "^11.13.1", "@types/node": "11.x",
"@types/node-forge": "^0.8.2", "@types/node-forge": "0.8.x",
"mocha": "^6.1.1", "mocha": "6.x",
"ts-node-dev": "^1.0.0-pre.32", "ts-node-dev": "^1.0.0-pre.32",
"typescript": "^3.4.2" "typedoc": "^0.14.2",
"typescript": "3.5.x"
}, },
"dependencies": {} "dependencies": {}
} }