https://github.com/bdmostafa/simplify
  
  
     
    https://github.com/bdmostafa/simplify
  
        Last synced: 2 months ago 
        JSON representation
    
- Host: GitHub
- URL: https://github.com/bdmostafa/simplify
- Owner: bdmostafa
- License: mit
- Created: 2021-02-12T10:23:25.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-02-15T06:30:33.000Z (over 4 years ago)
- Last Synced: 2025-03-16T21:37:46.913Z (8 months 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
[](https://www.npmjs.com/package/@mdmostafa/simplify)
[](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:1
makeToken("bangladesh", "secretKey");
//=> 331d261003455b2b3659af7f8c046a4dc96a9bc0d0692d714cff35775e5a25aa
makeToken("", "secretKey");
makeToken("bangladesh", "");
//=> TypeError: hash wants a string and secret key!
verifyToken("bangladesh", "secretKey");
//=> Your key is valid
verifyToken("bangladesh", "abcd");
//=> Your key/string is not valid
const 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!
```