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 🙏

© 2025 – Pkg Stats / Ryan Hefner

bacon-cipher

v0.1.0

Published

A robust JavaScript implementation of Bacon’s cipher, a.k.a. the Baconian cipher.

Downloads

12

Readme

bacon-cipher Build status Dependency status

bacon-cipher is a JavaScript implementation of Bacon’s cipher, a.k.a. the Baconian cipher. It can be used to encode plaintext to Bacon-ciphertext, or the other way around (i.e. decoding).

By default it uses the most common Bacon cipher alphabet, i.e. ABCDEFGHIKLMNOPQRSTUWXYZ (24 letters). This boils down to the following translations:

a   AAAAA   g     AABBA   n    ABBAA   t     BAABA
b   AAAAB   h     AABBB   o    ABBAB   u-v   BAABB
c   AAABA   i-j   ABAAA   p    ABBBA   w     BABAA
d   AAABB   k     ABAAB   q    ABBBB   x     BABAB
e   AABAA   l     ABABA   r    BAAAA   y     BABBA
f   AABAB   m     ABABB   s    BAAAB   z     BABBB

Installation

Via npm:

npm install bacon-cipher

Via Bower:

bower install bacon-cipher

Via Component:

component install mathiasbynens/bacon-cipher

In a browser:

<script src="bacon.js"></script>

In Narwhal, Node.js, and RingoJS:

var bacon = require('bacon-cipher');

In Rhino:

load('bacon.js');

Using an AMD loader like RequireJS:

require(
  {
    'paths': {
      'bacon': 'path/to/bacon'
    }
  },
  ['bacon'],
  function(bacon) {
    console.log(bacon);
  }
);

API

bacon.version

A string representing the semantic version number.

bacon.encode(text, options)

This function takes a string of text (the text parameter) and encrypts it using Bacon’s cipher.

bacon.encode('steganography');
// → 'BAAABBAABAAABAAAABBAAAAAAABBAAABBABAABBABAAAAAAAAAABBBAAABBBBABBA'

By default it uses the most common Bacon cipher alphabet, i.e. ABCDEFGHIKLMNOPQRSTUWXYZ (24 letters). In this case instances of J are replaced with I, and instances of V are replaced with U before further encoding the input string.

bacon.encode('James Vendetta');
// → 'ABAAAAAAAAABABBAABAABAAAB BAABBAABAAABBAAAAABBAABAABAABABAABAAAAAA'

It’s possible to pass an (optional) options object with an alphabet property to override the cipher alphabet. Note that in that case, no preprocessing (like replacing j and v) is done. For example, to use the full 26-letter alphabet:

bacon.encode('James Vendetta', {
  'alphabet': 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
});
// → 'ABAABAAAAAABBAAAABAABAABA BABABAABAAABBABAAABBAABAABAABBBAABBAAAAA'

bacon.decode(text, options)

This function takes a string of text (the text parameter) and decrypts it using Bacon’s cipher.

By default it uses the most common Bacon cipher alphabet, i.e. ABCDEFGHIKLMNOPQRSTUWXYZ (24 letters).

bacon.decode('BAAABBAABAAABAAAABBAAAAAAABBAAABBABAABBABAAAAAAAAAABBBAAABBBBABBA');
// → 'STEGANOGRAPHY'

bacon.decode('ABAAAAAAAAABABBAABAABAAAB BAABBAABAAABBAAAAABBAABAABAABABAABAAAAAA');
// → 'IAMES UENDETTA'

It’s possible to pass an (optional) options object with an alphabet property to override the cipher alphabet. For example, to use the full 26-letter alphabet:

bacon.decode('ABAABAAAAAABBAAAABAABAABA BABABAABAAABBABAAABBAABAABAABBBAABBAAAAA', {
  'alphabet': 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
});
// → 'JAMES VENDETTA'

Using the bacon binary

To use the bacon binary in your shell, simply install bacon-cipher globally using npm:

npm install -g bacon-cipher

After that you will be able to use Bacon’s cipher from the command line:

$ bacon --encode 'foo bar baz'
AABABABBABABBAB AAAABAAAAABAAAA AAAABAAAAABABBB

$ bacon --decode 'AABABABBABABBAB AAAABAAAAABAAAA AAAABAAAAABABBB'
FOO BAR BAZ

$ bacon --encode --alphabet=ABCDEFGHIJKLMNOPQRSTUVWXYZ 'Julius Caesar'
ABAABBABAAABABBABAAABABAABAABA AAABAAAAAAAABAABAABAAAAAABAAAB

$ bacon --decode --alphabet=ABCDEFGHIJKLMNOPQRSTUVWXYZ 'ABAABBABAAABABBABAAABABAABAABA AAABAAAAAAAABAABAABAAAAAABAAAB'
JULIUS CAESAR

Read a local text file, encrypt it using Bacon’s cipher with a non-default cipher alphabet, and save the result to a new file:

$ bacon --encode < foo.txt > foo-bacon.txt

Or do the same with an online text file:

$ curl -sL 'http://mths.be/brh' | bacon --encode > bacon.txt

Or, the opposite — read a local file containing Bacon ciphertext, decode it back to plain text, and save the result to a new file:

$ bacon --decode < bacon.txt > original.txt

See bacon --help for the full list of options.

Support

bacon is designed to work in at least Node.js v0.10.0, Narwhal 0.3.2, RingoJS 0.8-0.9, PhantomJS 1.9.0, Rhino 1.7RC4, as well as old and modern versions of Chrome, Firefox, Safari, Opera, and Internet Explorer.

Unit tests & code coverage

After cloning this repository, run npm install to install the dependencies needed for development and testing. You may want to install Istanbul globally using npm install istanbul -g.

Once that’s done, you can run the unit tests in Node using npm test or node tests/tests.js. To run the tests in Rhino, Ringo, Narwhal, and web browsers as well, use grunt test.

To generate the code coverage report, use grunt cover.

Author

| twitter/mathias | |---| | Mathias Bynens |

License

bacon is available under the MIT license.