Coding Challenge #2! (115)

105 Name: #!/usr/bin/anonymous : 2008-04-23 18:26 ID:6rn5Nb8P

reposting this from /prog/ (hi guys!) to compete in the 4K challenge:

<html><head><title>CBC using Mersenne Twister</title><style>body { color: white; background-color: black; }</style><script type="text/javascript">
N = 624;
M = 397;
MATRIX_A = 0x9908b0df;
UPPER_MASK = 0x80000000;
LOWER_MASK = 0x7fffffff;
var mt = new Array(N);
var mti = N+1;
function unsigned32 (n1) { return n1 < 0 ? (n1 ^ UPPER_MASK) + UPPER_MASK : n1; }
function subtraction32 (n1, n2) { return n1 < n2 ? unsigned32((0x100000000 - (n2 - n1)) & 0xffffffff) : n1 - n2; }
function addition32 (n1, n2) { return unsigned32((n1 + n2) & 0xffffffff) }
function multiplication32 (n1, n2) {var sum = 0;for (var i = 0; i < 32; ++i){if ((n1 >>> i) & 0x1){sum = addition32(sum, unsigned32(n2 << i));}}return sum;}
function init_genrand(s){mt[0]= unsigned32(s & 0xffffffff);for (mti=1; mti<N; mti++) {mt[mti] = addition32(multiplication32(1812433253, unsigned32(mt[mti-1] ^ (mt[mti-1] >>> 30))), mti);mt[mti] = unsigned32(mt[mti] & 0xffffffff);}}
function init_by_array(init_key, key_length){var i, j, k;init_genrand(19650218);i=1; j=0;k = (N>key_length ? N : key_length);for (; k; k--) {mt[i] = addition32(addition32(unsigned32(mt[i] ^ multiplication32(unsigned32(mt[i-1] ^ (mt[i-1] >>> 30)), 1664525)), init_key[j]), j);mt[i] = unsigned32(mt[i] & 0xffffffff);i++; j++; if (i>=N) { mt[0] = mt[N-1]; i=1; } if (j>=key_length) j=0; } for (k=N-1; k; k--) {mt[i] = subtraction32(unsigned32((dbg=mt[i]) ^ multiplication32(unsigned32(mt[i-1] ^ (mt[i-1] >>> 30)), 1566083941)), i);mt[i] = unsigned32(mt[i] & 0xffffffff);i++; if (i>=N) { mt[0] = mt[N-1]; i=1; } } mt[0] = 0x80000000; }
function genrand_int32() { var y; var mag01 = new Array(0x0, MATRIX_A); if (mti >= N) { var kk; if (mti == N+1) init_genrand(5489); for (kk=0;kk<N-M;kk++) { y = unsigned32((mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK)); mt[kk] = unsigned32(mt[kk+M] ^ (y >>> 1) ^ mag01[y & 0x1]); } for (;kk<N-1;kk++) { y = unsigned32((mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK)); mt[kk] = unsigned32(mt[kk+(M-N)] ^ (y >>> 1) ^ mag01[y & 0x1]); } y = unsigned32((mt[N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK)); mt[N-1] = unsigned32(mt[M-1] ^ (y >>> 1) ^ mag01[y & 0x1]); mti = 0; } y = mt[mti++]; y = unsigned32(y ^ (y >>> 11)); y = unsigned32(y ^ ((y << 7) & 0x9d2c5680)); y = unsigned32(y ^ ((y << 15) & 0xefc60000)); y = unsigned32(y ^ (y >>> 18)); return y; }
function l() { pass = document.getElementById("pass").value; if (pass) { init_by_array(pass,pass.length); return true; } else { alert('ENTER PASSWORD FIRST'); return false; } }
function dec2hex(i) { hex = "0123456789ABCDEF"; r = i % 16; s = hex.charAt((i-r)/16) + hex.charAt(r); return s; }
function e() { if (l()) { iv = Math.floor(Math.random()*256); body = document.getElementById("body").value; result = dec2hex(iv); for (i=0;i<body.length;i++) { if ((i+1)%30 == 0) result = result + "\n"; iv = (body.charCodeAt(i)+iv+genrand_int32())%256; result = result + dec2hex(iv); } document.getElementById("body").value = result; } }
function d() { if (l()) { r = /[^0-9A-F]/g; body = document.getElementById("body").value.replace(r,""); result = ""; for(i=1;(i*2)<body.length;i++) { s=(parseInt(body.substr(i*2,2),16)-parseInt(body.substr((i-1)*2,2),16)-genrand_int32()); if (s<0) { s=256-((-s)%256); } result = result + String.fromCharCode(s); } document.getElementById("body").value = result; } }
</script></head><body><form><pre>
Cipher Block Chaining using the Mersenne Twister (check wikipedia)

Password: <input class="inputText" type="password" value="anonIRCd" id="pass">

<textarea id="body" rows="20" cols="65"></textarea>

<input id="encrypt" type="button" value="Encrypt" onclick="e();"> <input id="decrypt" type="button" value="Decrypt" onclick="d();">
</pre></form></body></html>

what does anon think?

734DB4F1F24FC32D04E110418D7C99A74645CFDCFB1E5B035AE3EAACC821
96E71CD4A1EA902FC5EAB0DE2527C0E6954EF54839690166269E68C105DE
A6A9BD215CE6
Name: Link:
Leave these fields empty (spam trap):
More options...
Verification: