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

atbash-cipher

v1.0.1

Published

atbash cipher in javascript for nodejs and the browser

Downloads

13

Readme

atbash-cipher

atbash cipher in javascript for nodejs and the browser

demo: https://angeal185.github.io/atbash-cipher/

Installation

npm

$ npm install atbash-cipher --save

bower

$ bower install atbash-cipher

git

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

nodejs

const atbash = require('atbash-cipher')

browser

<script src="./dist/atbash.min.js"></script>

API


/**
 * shuffles your shift key (optional)
 *  @param {string} str ~ shift key
 **/
atbash.keygen(str)


/**
 *  callback
 *  @param {string} data ~ data to encrypt/decrypt
 *  @param {string} key ~ shift key
 *  @param {boolean} enc ~ true = encrypt | false = decrypt
 *  @param {function} cb ~ callback function(err,data)
 **/
atbash.shift(data, key, enc, cb) //returns callback


/**
 *  sync
 *  @param {string} data ~ data to encrypt/decrypt
 *  @param {string} key ~ shift key
 *  @param {boolean} enc ~ true = encrypt | false = decrypt
 **/
atbash.shiftSync(data, key, enc) //returns a string

/**
 *  promise
 *  @param {string} data ~ data to encrypt/decrypt
 *  @param {string} key ~ shift key
 *  @param {boolean} enc ~ true = encrypt | false = decrypt
 **/
atbash.shiftP(data, key, enc) //returns a promise


// demo

const atbash = require('atbash-cipher');

(function(){

  let test = '8476235846328abcdcdef',
  key = atbash.keygen('ABCDEF0123456789');

  //keygen
  console.log('keygen: '+ key)

  //sync
  console.log('sync test starting...')
  let syncEnc = atbash.shiftSync(test, key, true);
  console.log(syncEnc)
  let syncDec = atbash.shiftSync(syncEnc.data, key, false)
  console.log(syncDec)
  if(syncEnc.err){
    console.log('sync enc test failure.')
  } else if(syncDec.err){
    console.log('sync dec test failure.')
  } else {
    console.log('sync test done.')
  }

  //callback
  console.log('callback test starting...')
  atbash.shift(test, key, true, function(err,res){
    if(err){return console.log('callback enc test failure.')}
    console.log(res)
    atbash.shift(res.data, key, false, function(err,res){
      if(err){return console.log('callback dec test failure.')}
      console.log(res)
      console.log('callback test done.')
    })
  })

  // promise
  console.log('promise test starting...')
  atbash.shiftP(test, key, true).then(function(res){
    console.log(res)
    atbash.shiftP(res.data, key, false).then(function(res){
      console.log(res)
      console.log('promise test done.')
    }).catch(function(err){
      console.log('promise dec test failure.')
    })
  }).catch(function(err){
    console.log('promise enc test failure.')
  })
})()