Code Monkey home page Code Monkey logo

xor-crypt's Introduction

XOR-Crypt

Build Status NPM version NPM downloads Dependency Status Dev Dependency Status

Simple XOR string encryption library.

Install

  • Use: require('xor-crypt')
  • Install: npm install --save xor-crypt
  • Use: require('xor-crypt')
  • Install: npm install --save xor-crypt
  • CDN URL: //wzrd.in/bundle/[email protected]
  • Use: require('xor-crypt')
  • Install: ender add xor-crypt
  • Use: require('xor-crypt')
  • Install: component install RobLoach/xor-crypt
  • Use: require('xor-crypt')
  • Install: bower install xor-crypt

Usage

See the XOR-Crypt demonstration for a live usage of XOR-Crypt.

var encrypted = xorCrypt('Hello World');
// Outputs: Ncjji&Qitjb

var decrypted = xorCrypt(encrypted);
// Outputs: Hello World

// Use your own XOR Key.
var encrypted = xorCrypt('Hello World', 9);
var decrypted = xorCrypt(encrypted, 9);

Development

Install dependencies through npm:

npm install

Test with ESLint, Mocha and Mocha JSDom:

npm test

Build xor-crypt.min.js with:

npm run build

Tag and publish the new versions to npm with Semantic Versioning:

git tag 2.0.0
git push origin 2.0.0
npm publish

History

Discover the change history by heading on over to the HISTORY.md file.

License

Licensed under the incredibly permissive MIT license

xor-crypt's People

Contributors

robloach avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

xor-crypt's Issues

Improved version with support for buffers

const assert = require('assert')

function xor (data, key) {
  assert(data.length <= key.length, 'key length not equal/bigger data length')
  let out = Buffer.alloc(data.length)
  for (var i = 0; i < data.length; i++) {
    out[i] = data[i] ^ key[i]
  }
  return out
}

This improved version can encrypt buffers and use more than one-byte as encryption key

Example:

const crypto = require('crypto')
const key = crypto.randomBytes(16)
const msg = Buffer.from('hi')
const encrypted = xor(msg, key)
const decrypted = xor(encrypted, key)
console.log(String(decrypted))

str.charCodeAt is not a function

It says that at node_modules/xor-crypt/xor-crypt.js:42

output += String.fromCharCode(key ^ str.charCodeAt(i))
                                        ^

TypeError: str.charCodeAt is not a function
    at xorCrypt (<project folder>\node_modules\�[4mxor-crypt�[24m\xor-crypt.js:42:47)
    at <project folder>\index.js:8:27
�[90m    at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:63:3)�[39m

<project folder> is a replacement name, not the actual directory

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.