Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bdmostafa/simplify
https://github.com/bdmostafa/simplify
Last synced: about 17 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/bdmostafa/simplify
- Owner: bdmostafa
- License: mit
- Created: 2021-02-12T10:23:25.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-02-15T06:30:33.000Z (over 3 years ago)
- Last Synced: 2024-09-27T05:48:55.825Z (about 1 month ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/@mdmostafa/simplify
- Size: 7.81 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @mdmostafa/simplify
[![npm (scoped)](https://img.shields.io/npm/v/@mdmostafa/simplify.svg)](https://www.npmjs.com/package/@mdmostafa/simplify)
[![npm bundle size (minified)](https://img.shields.io/bundlephobia/min/@mdmostafa/simplify.svg)](https://www.npmjs.com/package/@mdmostafa/simplify)Removes all spaces from a string.
## Install
```
$ npm install @mdmostafa/simplify
```## Usage
```js
const { makeString, makeToken, verifyToken, Events, encrypt, decrypt } = require("@mdmostafa/simplify");makeString("Bangla desh");
//=> "Bangladesh!"makeString(1234);
//=> Uncaught TypeError: makeString wants a string!
// at simplify (:2:41)
// at :1:1makeToken("bangladesh", "secretKey");
//=> 331d261003455b2b3659af7f8c046a4dc96a9bc0d0692d714cff35775e5a25aamakeToken("", "secretKey");
makeToken("bangladesh", "");
//=> TypeError: hash wants a string and secret key!verifyToken("bangladesh", "secretKey");
//=> Your key is validverifyToken("bangladesh", "abcd");
//=> Your key/string is not validconst myEvent = new Events();
// Event listening
myEvent.listen('loadMsg');
//=> Listening to your event...
//=> Hello Bangladesh!// creating event with message
myEvent.log('loadMsg', 'Hello Bangladesh!');// Encrypt - Decrypt Usages text or buffer
const secretKey = 'OVH6sdmpNWjRR+qC*(7rdxs01lwH654@';const hash = encrypt('Hello Node JS!', secretKey);
const hashFromBuffer = encrypt(Buffer.from('Hello Node JS!', 'utf8'), secretKey);
console.log(hash);
//=> {
//=> iv: '418e5653829e3c902a4512e260ff356d',
//=> content: '9e6e67bd5715c72a47fb6434cd6a'
//=> }const txt = decrypt(hash, secretKey);
const txt2 = decrypt(hashFromBuffer, secretKey);console.log(txt);
//=> Hello Node JS!
console.log(txt2);
//=> Hello Node JS!```