PageSourceSearch

https://elearning.ucse.edu.ar//lib/javascript/calcMD5.js?v=1787049104

js ucse.edu.ar collected 2026-10-02 11:54:50 UTC 5,601 bytes, 175 lines download raw bytes

1/***********************************************************/
2/*                                                         */
3/* Plataforma e-ducativa - Argentina                       */
4/*                                                         */
5/* Copyright (c) 2026 de e-ducativa Educación Virtual S.A. */
6/*                                                         */
7/***********************************************************/
8//Para calcular el MD5 de la clave en procesos de inicio de sesion
9
10/*
11 * Convert a 32-bit number to a hex string with ls-byte first
12 */
13var hex_chr = "0123456789abcdef";
14
15function rhex(num)
16{
17	str = "";
18	for(j = 0; j <= 3; j++)
19		str += hex_chr.charAt((num >> (j * 8 + 4)) & 0x0F) +
20			hex_chr.charAt((num >> (j * 8)) & 0x0F);
21	return str;
22}
23
24/*
25 * Convert a string to a sequence of 16-word blocks, stored as an array.
26 * Append padding bits and the length, as described in the MD5 standard.
27 */
28function str2blks_MD5(str)
29{
30	nblk = ((str.length + 8) >> 6) + 1;
31	blks = new Array(nblk * 16);
32	for(i = 0; i < nblk * 16; i++) blks[i] = 0;
33	for(i = 0; i < str.length; i++)
34		blks[i >> 2] |= str.charCodeAt(i) << ((i % 4) * 8);
35	blks[i >> 2] |= 0x80 << ((i % 4) * 8);
36	blks[nblk * 16 - 2] = str.length * 8;
37	return blks;
38}
39
40/*
41 * Add integers, wrapping at 2^32. This uses 16-bit operations internally
42 * to work around bugs in some JS interpreters.
43 */
44function add(x, y)
45{
46	var lsw = (x & 0xFFFF) + (y & 0xFFFF);
47	var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
48	return (msw << 16) | (lsw & 0xFFFF);
49}
50
51/*
52 * Bitwise rotate a 32-bit number to the left
53 */
54function rol(num, cnt)
55{
56	return (num << cnt) | (num >>> (32 - cnt));
57}
58
59/*
60 * These functions implement the basic operation for each round of the
61 * algorithm.
62 */
63function cmn(q, a, b, x, s, t)
64{
65	return add(rol(add(add(a, q), add(x, t)), s), b);
66}
67
68function ff(a, b, c, d, x, s, t)
69{
70	return cmn((b & c) | ((~b) & d), a, b, x, s, t);
71}
72
73function gg(a, b, c, d, x, s, t)
74{
75	return cmn((b & d) | (c & (~d)), a, b, x, s, t);
76}
77
78function hh(a, b, c, d, x, s, t)
79{
80	return cmn(b ^ c ^ d, a, b, x, s, t);
81}
82
83function ii(a, b, c, d, x, s, t)
84{
85	return cmn(c ^ (b | (~d)), a, b, x, s, t);
86}
87
88/*
89 * Take a string and return the hex representation of its MD5.
90 */
91function calcMD5(str)
92{
93	x = str2blks_MD5(str);
94	a =  1732584193;
95	b = -271733879;
96	c = -1732584194;
97	d =  271733878;
98	for(i = 0; i < x.length; i += 16)
99	{
100		olda = a;
101		oldb = b;
102		oldc = c;
103		oldd = d;
104		a = ff(a, b, c, d, x[i+ 0], 7 , -680876936);
105		d = ff(d, a, b, c, x[i+ 1], 12, -389564586);
106		c = ff(c, d, a, b, x[i+ 2], 17,  606105819);
107		b = ff(b, c, d, a, x[i+ 3], 22, -1044525330);
108		a = ff(a, b, c, d, x[i+ 4], 7 , -176418897);
109		d = ff(d, a, b, c, x[i+ 5], 12,  1200080426);
110		c = ff(c, d, a, b, x[i+ 6], 17, -1473231341);
111		b = ff(b, c, d, a, x[i+ 7], 22, -45705983);
112		a = ff(a, b, c, d, x[i+ 8], 7 ,  1770035416);
113		d = ff(d, a, b, c, x[i+ 9], 12, -1958414417);
114		c = ff(c, d, a, b, x[i+10], 17, -42063);
115		b = ff(b, c, d, a, x[i+11], 22, -1990404162);
116		a = ff(a, b, c, d, x[i+12], 7 ,  1804603682);
117		d = ff(d, a, b, c, x[i+13], 12, -40341101);
118		c = ff(c, d, a, b, x[i+14], 17, -1502002290);
119		b = ff(b, c, d, a, x[i+15], 22,  1236535329);
120		a = gg(a, b, c, d, x[i+ 1], 5 , -165796510);
121		d = gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
122		c = gg(c, d, a, b, x[i+11], 14,  643717713);
123		b = gg(b, c, d, a, x[i+ 0], 20, -373897302);
124		a = gg(a, b, c, d, x[i+ 5], 5 , -701558691);
125		d = gg(d, a, b, c, x[i+10], 9 ,  38016083);
126		c = gg(c, d, a, b, x[i+15], 14, -660478335);
127		b = gg(b, c, d, a, x[i+ 4], 20, -405537848);
128		a = gg(a, b, c, d, x[i+ 9], 5 ,  568446438);
129		d = gg(d, a, b, c, x[i+14], 9 , -1019803690);
130		c = gg(c, d, a, b, x[i+ 3], 14, -187363961);
131		b = gg(b, c, d, a, x[i+ 8], 20,  1163531501);
132		a = gg(a, b, c, d, x[i+13], 5 , -1444681467);
133		d = gg(d, a, b, c, x[i+ 2], 9 , -51403784);
134		c = gg(c, d, a, b, x[i+ 7], 14,  1735328473);
135		b = gg(b, c, d, a, x[i+12], 20, -1926607734);
136		a = hh(a, b, c, d, x[i+ 5], 4 , -378558);
137		d = hh(d, a, b, c, x[i+ 8], 11, -2022574463);
138		c = hh(c, d, a, b, x[i+11], 16,  1839030562);
139		b = hh(b, c, d, a, x[i+14], 23, -35309556);
140		a = hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
141		d = hh(d, a, b, c, x[i+ 4], 11,  1272893353);
142		c = hh(c, d, a, b, x[i+ 7], 16, -155497632);
143		b = hh(b, c, d, a, x[i+10], 23, -1094730640);
144		a = hh(a, b, c, d, x[i+13], 4 ,  681279174);
145		d = hh(d, a, b, c, x[i+ 0], 11, -358537222);
146		c = hh(c, d, a, b, x[i+ 3], 16, -722521979);
147		b = hh(b, c, d, a, x[i+ 6], 23,  76029189);
148		a = hh(a, b, c, d, x[i+ 9], 4 , -640364487);
149		d = hh(d, a, b, c, x[i+12], 11, -421815835);
150		c = hh(c, d, a, b, x[i+15], 16,  530742520);
151		b = hh(b, c, d, a, x[i+ 2], 23, -995338651);
152		a = ii(a, b, c, d, x[i+ 0], 6 , -198630844);
153		d = ii(d, a, b, c, x[i+ 7], 10,  1126891415);
154		c = ii(c, d, a, b, x[i+14], 15, -1416354905);
155		b = ii(b, c, d, a, x[i+ 5], 21, -57434055);
156		a = ii(a, b, c, d, x[i+12], 6 ,  1700485571);
157		d = ii(d, a, b, c, x[i+ 3], 10, -1894986606);
158		c = ii(c, d, a, b, x[i+10], 15, -1051523);
159		b = ii(b, c, d, a, x[i+ 1], 21, -2054922799);
160		a = ii(a, b, c, d, x[i+ 8], 6 ,  1873313359);
161		d = ii(d, a, b, c, x[i+15], 10, -30611744);
162		c = ii(c, d, a, b, x[i+ 6], 15, -1560198380);
163		b = ii(b, c, d, a, x[i+13], 21,  1309151649);
164		a = ii(a, b, c, d, x[i+ 4], 6 , -145523070);
165		d = ii(d, a, b, c, x[i+11], 10, -1120210379);
166		c = ii(c, d, a, b, x[i+ 2], 15,  718787259);
167		b = ii(b, c, d, a, x[i+ 9], 21, -343485551);
168		a = add(a, olda);
169		b = add(b, oldb);
170		c = add(c, oldc);
171		d = add(d, oldd);
172	}
173	return rhex(a) + rhex(b) + rhex(c) + rhex(d);
174}
175

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.