rjutils-collection
Advanced tools
Comparing version 1.0.4 to 1.0.5
{ | ||
"name": "rjutils-collection", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Easy and Lightweight Utilities", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -24,2 +24,8 @@ <h1 align="center">Welcome to rjutils-collection 👋</h1> | ||
or | ||
```sh | ||
yarn add rjutils-collection | ||
``` | ||
## Usage | ||
@@ -64,2 +70,37 @@ | ||
Encrypting a String | ||
```js | ||
const utils = require('rjutils-collection') | ||
const result = utils.encryptString({ | ||
text: 'Hello, World!', | ||
algorithm: 'sha256', | ||
key: '123456789', | ||
output: 'hex' | ||
}) | ||
``` | ||
Decrypting a String | ||
```js | ||
const utils = require('rjutils-collection') | ||
const result = utils.decryptString({ | ||
text: 'cf5ca2c244e71e33e30d07d5c13a4502!', | ||
algorithm: 'sha256', | ||
key: '123456789', | ||
output: 'utf8' | ||
}) | ||
``` | ||
Hashing a String | ||
```js | ||
const utils = require('rjutils-collection') | ||
const result = utils.hashString({ | ||
text: 'Hello World again!', | ||
algorithm: 'sha256', | ||
digest: 'hex' | ||
}) | ||
``` | ||
## Author | ||
@@ -66,0 +107,0 @@ |
@@ -127,3 +127,3 @@ const path = require('path') | ||
* @prop {String} [algorithm] The Algorithm to use | ||
* @prop {String} [digest] The Text Output (base64, base64url, binary, hex) | ||
* @prop {String} [digest] The Text Output (base64, base64url, binary, hex, bytes) | ||
* @prop {String} text The Text to Hash | ||
@@ -130,0 +130,0 @@ * |
@@ -34,5 +34,7 @@ const crypto = require('crypto') | ||
const hash = crypto.createHash(algorithm).update(String(options.text)).digest(digest).substring(0, 32) | ||
let hash | ||
if (digest === 'bytes') hash = crypto.createHash(algorithm).update(String(options.text)) | ||
else hash = crypto.createHash(algorithm).update(String(options.text)).digest(digest) | ||
return hash | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11430
204
119