JSFiddle - React, Tailwind, and code Playground
by jaygiri
HTML
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/md5.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/sha1.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/sha256.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/sha512.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/sha3.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/ripemd160.js"></script>
JavaScript
// Note that we assume ascii strings, not unicode.
// A better implementation should use array buffers
// of bytes, and force a conversion before executing,
// and convert outputs back into strings.
(function(exports) {
var base32 = {
a: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",
pad: "=",
encode: function (s) {
var a = this.a;
var pad = this.pad;
var len = s.length;
var o = "";
var w, c, r=0, sh=0;
for(i=0; i<len; i+=5) {
// mask top 5 bits
c = s.charCodeAt(i);
w = 0xf8 & c;
o += a.charAt(w>>3);
r = 0x07 & c;
sh = 2;
if ((i+1)<len) {
c = s.charCodeAt(i+1);
// mask top 2 bits
w = 0xc0 & c;
o += a.charAt((r<<2) + (w>>6));
o += a.charAt( (0x3e & c) >> 1 );
r = c & 0x01;
sh = 4;
}
if ((i+2)<len) {
c = s.charCodeAt(i+2);
// mask top 4 bits
w = 0xf0 & c;
o += a.charAt((r<<4) + (w>>4));
r = 0x0f & c;
sh = 1;
}
if ((i+3)<len) {
c = s.charCodeAt(i+3);
// mask top 1 bit
w = 0x80 &...