Skip to content
A cross-browser js library for hashing text to a format which can be displayed as a png
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
examples
src
.gitignore
LICENSE
README.md

README.md

pngCipher

A js library for hashing text to a format which can be displayed as a png

Quickstart

// encode data
pngCipher.encode(text, function(hash) {
	console.log(hash);
	document.querySelector('#image').src = "data:image/png;base64,"+ hash;
});

// decode a hashed string
pngCipher.decode(hash, onError, onSuccess);

function onError(err) {
	alert("There's been an error!\n\n" + err);
}

function onSuccess(text) {
	console.log(text);
}

Intro

This library can be used to encode any string to a format that can be displayed as a png. It can also be used to decode previously hashed png images.

This library does NOT depend on the browser's canvas functionality, and therefore WILL produce identical hashes accross different browsers [1][2]

Below is the introduction of Marijn Haverbeke's excellent book, "Eloquent JavaScript" in png format:

Eloquent JS

Please note a few things:

  1. For now, the input string must be limited to the first 255 characters (i.e. codes 0 - 254 ) as defined by the 256 ASCII code table.

  2. This is in NO WAY a secure hashing method. If you want to securely store something in a png, you'll need to first securely hash your string before calling the encoder.

WHY?!

You might be asking yourself, "Why in the world would anyone want to use this?!" Well, one reason is that some mediums of communication don't allow users to attach zipfiles. A good example is MMS. However, MMS WILL allow users to send / receive images. Using this library, large amounts of data could be sent over MMS as images.

Also, I got bored on a Friday afternoon...

Browserfy

If you want to use this in the browser, you can either use the minified file included in the dist folder, or you can build from source with browserfy:

$ browserify index.js --standalone pngCipher > ../dist/pngCipher.js

You can’t perform that action at this time.