Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
hex-xor-cipher
Advanced tools
xor cipher for shift base encrypting and decrypting hexadecimal string
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.
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 git@github.com:angeal185/hex-xor-cipher.git
const hx = require('hex-xor-cipher')
<script src="./path-to/lodash.min.js"></script>
<script src="./dist/hex-xor.min.js"></script>
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
//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 */
FAQs
xor cipher for shift base encrypting and decrypting hexadecimal string
The npm package hex-xor-cipher receives a total of 3 weekly downloads. As such, hex-xor-cipher popularity was classified as not popular.
We found that hex-xor-cipher demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.