Giter Club home page Giter Club logo

simplify's Introduction

@mdmostafa/simplify

npm (scoped) npm bundle size (minified)

Removes all spaces from a string.

Install

$ npm install @mdmostafa/simplify

Usage

const { makeString, makeToken, verifyToken, Events, encrypt, decrypt } = require("@mdmostafa/simplify");

makeString("Bangla desh");
//=> "Bangladesh!"

makeString(1234);
//=> Uncaught TypeError: makeString wants a string!
//    at simplify (<anonymous>:2:41)
//    at <anonymous>: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!

simplify's People

Contributors

bdmostafa avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.