This repository has been archived by the owner. It is now read-only.
crypt(3) Implementation for JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
LICENSE
README.md
crypt.js
demo.html
demo.js
original.c
style.css

README.md

JavaScript crypt(3) Implementation

JavaScript port of crypt(3) function.

char *crypt(const char *key, const char *salt);

A original C version is written by Michael Dipperstein.

How to use

Include crypt.js:

<script type="text/javascript" src="crypt.js"></script>

Then, call a "Crypt" function

// Helper function that convert string to utf8 byte array.
function toUTF8Array(str) {
	var utf8 = unescape( encodeURIComponent(utf8) );
	var arr = [];
	for (var i = 0; i < utf8.length; i++) {
		arr.push(utf8.charCodeAt(i));
	}
	return arr;
}
// Crypt accepts only Array object.
// Crypt(password, salt)
var hash = Crypt(toUTF8Array("password"), toUTF8Array("sa"));