npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mb-encrypt

v1.3.1

Published

A powerful library for encrypting and decrypting JSON and string objects.

Downloads

15

Readme

Mybutton Encryption Tool (MET)

Mybutton Encryption is a way of encrypting JSON string objects with a key letter.

Install Using npm

$ npm install mb-encrypt --s

Example usage

For example, lets say that we have a server and we encrypt our packages with this service.
const mbencrypt = require('mb-encrypt');
//define the object
const string = JSON.stringify({server: {
		ip: 1.1.1.1, //example
		password: "CLIENT-CONNECTION-TEST" 
	}
})

//encrypt it with the key 'key'.
const responseEncoded = mbencrypt.encrypt(string, 'key');
server.send(client.ip, responseEncoded);
//done!
Now, in our client, we can get the response and decode it with the key.
const mbencrypt = require('mb-encrypt');
//response from the server
const response = request.server.response; //encoded JSON string object
const decodedString = mbencrypt.decrypt(response, 'key');
const jsonObject = JSON.parse(decodedString);
console.log(jsonObject) 
//the client was able to decode it with the key 'c'.
But in another client which isn't our client, attempting to get data would be gibberish.
//client made a request
const response = request.server.response
console.log(response)
//returns: {\"SHGJKFK\": \"FHJGKDKEI.FJJEDLSOE\"};

Support

FarewellNehir (Lead Developer, Mybutton Corporation CEO) [contact]

An Explanation of the Algorithm

The algorithm concludes of a complicated math algorithm.
//Let's say we have 'test, hello!' as our string and 'g' as our key.
const string = 'test, hello!';
const key = 'key';
//decoding 
const charArray = [...string] //turn it into a character array.
var encodedText = "";
foreach (letter in charArray) {
if (regex.test(letter)) encodedText += letter;
if (letter == " ") encodedText += letter;
if (typeof letter == "number") encodedText += letter;
	const letterOrderInAlphabet = new String(letter).toLocaleUpperCase().charCodeAt(0) - letterOrder.a;
	const keyOrderInAlphabet = new String(key).toLocaleUpperCase().charCodeAt(0) - letterOrder.a;
	const resolution = (x, y) => return x - (y^2 + x + x * (x + y)(x-y), y^2 - x^2 * (x-y)(x+y));
	const valueAsCharOrder = resolution(charAsOrder, keyAsOrder) - 26 + 65; //get the order of the first decode of the letter, delete 26, which is the amount of letters in the alphabet, and then 65, which is the charCode of A, the first letter.
	const decode = (char, key) => char = char.order + ((char.order - (key.order * char.order)) * (key.order^2)) //decode the character from the original decoded letter to return the charOrderInAlphabet value of the original text string, and add +65 (letter A charCode)
	const decodedCharOrderInAlphabet = decode(valueAsCharOrder, keyAsOrder); 
	const stringifiedCharCode = String.fromCharCode(decodedCharOrderInAlphabet + letterOrder.a); //turn it to a letter from the char code of the original character
	encodedText += stringifiedCharCode; //add it to the text
	
}
//final result
return encodedText;