MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / md51

Function md51

scripts/libs/crypto/md5.js:104–123  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

102}
103
104function md51(s) {
105 var n = s.length,
106 state = [1732584193, -271733879, -1732584194, 271733878],
107 i;
108 for (i = 64; i <= s.length; i += 64) {
109 md5cycle(state, md5blk(s.substring(i - 64, i)));
110 }
111 s = s.substring(i - 64);
112 var tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
113 for (i = 0; i < s.length; i++)
114 tail[i >> 2] |= s.charCodeAt(i) << (i % 4 << 3);
115 tail[i >> 2] |= 0x80 << (i % 4 << 3);
116 if (i > 55) {
117 md5cycle(state, tail);
118 for (i = 0; i < 16; i++) tail[i] = 0;
119 }
120 tail[14] = n * 8;
121 md5cycle(state, tail);
122 return state;
123}
124
125/* there needs to be support for Unicode here,
126 * unless we pretend that we can redefine the MD-5

Callers 1

md5Function · 0.85

Calls 2

md5cycleFunction · 0.85
md5blkFunction · 0.85

Tested by

no test coverage detected