time-to-botec/squiggle/node_modules/@rescript/std/lib/es6/caml_md5.js
NunoSempere b6addc7f05 feat: add the node modules
Necessary in order to clearly see the squiggle hotwiring.
2022-12-03 12:44:49 +00:00

169 lines
5.0 KiB
JavaScript

function cmn(q, a, b, x, s, t) {
var a$1 = ((a + q | 0) + x | 0) + t | 0;
return ((a$1 << s) | (a$1 >>> (32 - s | 0)) | 0) + b | 0;
}
function f(a, b, c, d, x, s, t) {
return cmn(b & c | (b ^ -1) & d, a, b, x, s, t);
}
function g(a, b, c, d, x, s, t) {
return cmn(b & d | c & (d ^ -1), a, b, x, s, t);
}
function h(a, b, c, d, x, s, t) {
return cmn(b ^ c ^ d, a, b, x, s, t);
}
function i(a, b, c, d, x, s, t) {
return cmn(c ^ (b | d ^ -1), a, b, x, s, t);
}
function cycle(x, k) {
var a = x[0];
var b = x[1];
var c = x[2];
var d = x[3];
a = f(a, b, c, d, k[0], 7, -680876936);
d = f(d, a, b, c, k[1], 12, -389564586);
c = f(c, d, a, b, k[2], 17, 606105819);
b = f(b, c, d, a, k[3], 22, -1044525330);
a = f(a, b, c, d, k[4], 7, -176418897);
d = f(d, a, b, c, k[5], 12, 1200080426);
c = f(c, d, a, b, k[6], 17, -1473231341);
b = f(b, c, d, a, k[7], 22, -45705983);
a = f(a, b, c, d, k[8], 7, 1770035416);
d = f(d, a, b, c, k[9], 12, -1958414417);
c = f(c, d, a, b, k[10], 17, -42063);
b = f(b, c, d, a, k[11], 22, -1990404162);
a = f(a, b, c, d, k[12], 7, 1804603682);
d = f(d, a, b, c, k[13], 12, -40341101);
c = f(c, d, a, b, k[14], 17, -1502002290);
b = f(b, c, d, a, k[15], 22, 1236535329);
a = g(a, b, c, d, k[1], 5, -165796510);
d = g(d, a, b, c, k[6], 9, -1069501632);
c = g(c, d, a, b, k[11], 14, 643717713);
b = g(b, c, d, a, k[0], 20, -373897302);
a = g(a, b, c, d, k[5], 5, -701558691);
d = g(d, a, b, c, k[10], 9, 38016083);
c = g(c, d, a, b, k[15], 14, -660478335);
b = g(b, c, d, a, k[4], 20, -405537848);
a = g(a, b, c, d, k[9], 5, 568446438);
d = g(d, a, b, c, k[14], 9, -1019803690);
c = g(c, d, a, b, k[3], 14, -187363961);
b = g(b, c, d, a, k[8], 20, 1163531501);
a = g(a, b, c, d, k[13], 5, -1444681467);
d = g(d, a, b, c, k[2], 9, -51403784);
c = g(c, d, a, b, k[7], 14, 1735328473);
b = g(b, c, d, a, k[12], 20, -1926607734);
a = h(a, b, c, d, k[5], 4, -378558);
d = h(d, a, b, c, k[8], 11, -2022574463);
c = h(c, d, a, b, k[11], 16, 1839030562);
b = h(b, c, d, a, k[14], 23, -35309556);
a = h(a, b, c, d, k[1], 4, -1530992060);
d = h(d, a, b, c, k[4], 11, 1272893353);
c = h(c, d, a, b, k[7], 16, -155497632);
b = h(b, c, d, a, k[10], 23, -1094730640);
a = h(a, b, c, d, k[13], 4, 681279174);
d = h(d, a, b, c, k[0], 11, -358537222);
c = h(c, d, a, b, k[3], 16, -722521979);
b = h(b, c, d, a, k[6], 23, 76029189);
a = h(a, b, c, d, k[9], 4, -640364487);
d = h(d, a, b, c, k[12], 11, -421815835);
c = h(c, d, a, b, k[15], 16, 530742520);
b = h(b, c, d, a, k[2], 23, -995338651);
a = i(a, b, c, d, k[0], 6, -198630844);
d = i(d, a, b, c, k[7], 10, 1126891415);
c = i(c, d, a, b, k[14], 15, -1416354905);
b = i(b, c, d, a, k[5], 21, -57434055);
a = i(a, b, c, d, k[12], 6, 1700485571);
d = i(d, a, b, c, k[3], 10, -1894986606);
c = i(c, d, a, b, k[10], 15, -1051523);
b = i(b, c, d, a, k[1], 21, -2054922799);
a = i(a, b, c, d, k[8], 6, 1873313359);
d = i(d, a, b, c, k[15], 10, -30611744);
c = i(c, d, a, b, k[6], 15, -1560198380);
b = i(b, c, d, a, k[13], 21, 1309151649);
a = i(a, b, c, d, k[4], 6, -145523070);
d = i(d, a, b, c, k[11], 10, -1120210379);
c = i(c, d, a, b, k[2], 15, 718787259);
b = i(b, c, d, a, k[9], 21, -343485551);
x[0] = a + x[0] | 0;
x[1] = b + x[1] | 0;
x[2] = c + x[2] | 0;
x[3] = d + x[3] | 0;
}
var state = [
1732584193,
-271733879,
-1732584194,
271733878
];
var md5blk = [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
];
function md5_string(s, start, len) {
var s$1 = s.slice(start, len);
var n = s$1.length;
state[0] = 1732584193;
state[1] = -271733879;
state[2] = -1732584194;
state[3] = 271733878;
for(var i = 0; i <= 15; ++i){
md5blk[i] = 0;
}
var i_end = n / 64 | 0;
for(var i$1 = 1; i$1 <= i_end; ++i$1){
for(var j = 0; j <= 15; ++j){
var k = ((i$1 << 6) - 64 | 0) + (j << 2) | 0;
md5blk[j] = ((s$1.charCodeAt(k) + (s$1.charCodeAt(k + 1 | 0) << 8) | 0) + (s$1.charCodeAt(k + 2 | 0) << 16) | 0) + (s$1.charCodeAt(k + 3 | 0) << 24) | 0;
}
cycle(state, md5blk);
}
var s_tail = s$1.slice((i_end << 6));
for(var kk = 0; kk <= 15; ++kk){
md5blk[kk] = 0;
}
var i_end$1 = s_tail.length - 1 | 0;
for(var i$2 = 0; i$2 <= i_end$1; ++i$2){
md5blk[i$2 / 4 | 0] = md5blk[i$2 / 4 | 0] | (s_tail.charCodeAt(i$2) << (i$2 % 4 << 3));
}
var i$3 = i_end$1 + 1 | 0;
md5blk[i$3 / 4 | 0] = md5blk[i$3 / 4 | 0] | (128 << (i$3 % 4 << 3));
if (i$3 > 55) {
cycle(state, md5blk);
for(var i$4 = 0; i$4 <= 15; ++i$4){
md5blk[i$4] = 0;
}
}
md5blk[14] = (n << 3);
cycle(state, md5blk);
return String.fromCharCode(state[0] & 255, (state[0] >> 8) & 255, (state[0] >> 16) & 255, (state[0] >> 24) & 255, state[1] & 255, (state[1] >> 8) & 255, (state[1] >> 16) & 255, (state[1] >> 24) & 255, state[2] & 255, (state[2] >> 8) & 255, (state[2] >> 16) & 255, (state[2] >> 24) & 255, state[3] & 255, (state[3] >> 8) & 255, (state[3] >> 16) & 255, (state[3] >> 24) & 255);
}
export {
md5_string ,
}
/* No side effect */