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

hex-xor-cipher

v1.0.0

Published

xor cipher for shift base encrypting and decrypting hexadecimal string

Downloads

10

Readme

hex-xor-cipher

xor cipher for shift base encrypting and decrypting hexadecimal string

Adds an extra layer of protection to your already encrypted code's hex output by essentially turning it into nothing but valid hex.

Installation

demo: https://angeal185.github.io/hex-xor-cipher/

npm

$ npm install hex-xor-cipher --save

bower

$ bower install hex-xor-cipher --save

git

$ git clone [email protected]:angeal185/hex-xor-cipher.git

nodejs

const hx = require('hex-xor-cipher')

browser

<script src="./path-to/lodash.min.js"></script>
<script src="./dist/hex-xor.min.js"></script>

info

  • Adds a shif-based hex-xor to a valid hex string
  • 000000 with a shift value of 1 would become 1f1f1f
  • 000000 with a shift value of 2 would become 2e2e2e
  • 000000 with a shift value of 1 and {reverse: true} would become f1f1f1
  • 000000 with a shift value of 1 and {uppercase: true} would become F1F1F1
  • 000000 with a shift value of 1 and {buff: [1,2]} might become 73f1f1f1c48e

API

//default options
{
    reverse: false, // {boolean} ~ reverse hex string
    uppercase: false, //  {boolean} ~ output uppercase hex
    buff: false //  {boolean/array} ~ prepend/append random hex buffer  
}
/*
* reverse should be set to either true or false for both
  encrypt/decrypt ~ default: false

* buff accepts either a boolean for false or an array for true.
  ~ [1,2] would prepend/slice 1 byte(2 hex chars) to the start
    and append/slice 2 bytes(4 hex chars) of random data to the end
*/


/**
 *  callback
 *  htc.enc(hex, key, config, cb) / htc.dec(hex, key, config, cb)
 *  @param {string} hex ~ valid hex string
 *  @param {integer} shift ~ integer between 1-15
 *  @param {object} config ~ optional options
 *  @param {function} cb ~ callback function(err,data)
 **/

hx.enc(testStr, shift, config, cb) //returns callback
hx.dec(testStr, shift, config, cb) //returns callback

/**
 *  sync
 *  htc.encSync(hex, key, config)
 *  @param {string} hex ~ valid hex string
 *  @param {integer} shift ~ integer between 1-15
 *  @param {object} config ~ optional options
 **/

hx.encSync(testStr, shift, config) //returns a string
hx.decSync(testStr, shift, config) //returns a string

/**
 *  promise
 *  hx.encP(testStr, shift) / hx.decP(testStr, shift)
 *  @param {string} hex ~ valid hex string
 *  @param {integer} shift ~ integer between 1-15
 *  @param {object} config ~ optional options
 **/

hx.encP(testStr, shift, config) //returns a promise
hx.decP(testStr, shift, config) //returns a promise

// demo
const testStr = '01234567890abcdef',
shift = 1,
config = {
    reverse: true,
    uppercase: true,
    buff: [2,4]
}
/* callback */
//encrypt
hx.enc(testStr, shift, config, function(err, data){
    if(err){return console.log(err)}
    console.log(data)

    // decrypt
    hx.dec(data, shift, config, function(err,data){
      if(err){return console.log(err)}
      console.log(data)
    })
})
/* end callback */

/* sync */
// encrypt
let encSync = hx.encSync(testStr, shift, config),
// decrypt
decSync = hx.decSync(encSync, shift, config);
console.log('sync enc: ' + encSync)
console.log('sync dec: ' + decSync)
/* end sync */

/* promise */
//encrypt
hx.encP(testStr, shift, config).then(function(res) {
    console.log('promise enc: ' + res);

    //decript
    hx.decP(res, shift, config).then(function(res) {
      console.log('promise dec: ' + res);
    }).catch(function(err){
      console.log(err)
    });

}).catch(function(err){
    console.log(err)
});
/* end promise */