diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/arris.js | 50 | ||||
-rw-r--r-- | js/arris.minimized.js | 1 |
2 files changed, 29 insertions, 22 deletions
diff --git a/js/arris.js b/js/arris.js index 950ae33..f52e898 100644 --- a/js/arris.js +++ b/js/arris.js @@ -1,10 +1,21 @@ -var sys = require("sys"); +/* +var sys = require("sys") function log(x) { -// sys.print("" + x + "\n"); + sys.print("" + x + "\n"); } +*/ + +function calculatePasswordOfDay(date) { + if (typeof(log) == "undefined") { + var log = function(msg) { } + } + + var year = (date.getYear()+1900) % 1000; + var month = date.getMonth()+1; + var day = date.getDate(); + var weekday = date.getDay()-1; -function calculatePasswordOfDay() { var seedeight = "MPSJKMDH" var seedten = "MPSJKMDHAI" @@ -36,13 +47,7 @@ function calculatePasswordOfDay() { var buffer = [] var buffer6 = [] var bufferResult = [] - - var year = 2010 % 1000; - var month = 10; - var day = 20; - var weekday = 3-1; - - + bufferWeekday[0] = sboxWeekday[weekday][0]; bufferWeekday[1] = sboxWeekday[weekday][1]; bufferWeekday[2] = sboxWeekday[weekday][2]; @@ -92,16 +97,16 @@ function calculatePasswordOfDay() { buffer6[9] = buffer[sbox2[bufferNum][9]] log("buffer6=" + buffer6) - bufferResult[0] = ((seedten.charCodeAt(0) + buffer6[0]) % 0x24); - bufferResult[1] = ((seedten.charCodeAt(1) + buffer6[1]) % 0x24); - bufferResult[2] = ((seedten.charCodeAt(2) + buffer6[2]) % 0x24); - bufferResult[3] = ((seedten.charCodeAt(3) + buffer6[3]) % 0x24); - bufferResult[4] = ((seedten.charCodeAt(4) + buffer6[4]) % 0x24); - bufferResult[5] = ((seedten.charCodeAt(5) + buffer6[5]) % 0x24); - bufferResult[6] = ((seedten.charCodeAt(6) + buffer6[6]) % 0x24); - bufferResult[7] = ((seedten.charCodeAt(7) + buffer6[7]) % 0x24); - bufferResult[8] = ((seedten.charCodeAt(8) + buffer6[8]) % 0x24); - bufferResult[9] = ((seedten.charCodeAt(9) + buffer6[9]) % 0x24); + bufferResult[0] = (seedten.charCodeAt(0) + buffer6[0]) % 0x24; + bufferResult[1] = (seedten.charCodeAt(1) + buffer6[1]) % 0x24; + bufferResult[2] = (seedten.charCodeAt(2) + buffer6[2]) % 0x24; + bufferResult[3] = (seedten.charCodeAt(3) + buffer6[3]) % 0x24; + bufferResult[4] = (seedten.charCodeAt(4) + buffer6[4]) % 0x24; + bufferResult[5] = (seedten.charCodeAt(5) + buffer6[5]) % 0x24; + bufferResult[6] = (seedten.charCodeAt(6) + buffer6[6]) % 0x24; + bufferResult[7] = (seedten.charCodeAt(7) + buffer6[7]) % 0x24; + bufferResult[8] = (seedten.charCodeAt(8) + buffer6[8]) % 0x24; + bufferResult[9] = (seedten.charCodeAt(9) + buffer6[9]) % 0x24; log("bufferResult=" + bufferResult) var out = ""; @@ -111,5 +116,6 @@ function calculatePasswordOfDay() { return out; } - -sys.print(calculatePasswordOfDay() + "\n") +/* +sys.print(calculatePasswordOfDay(new Date()) + "\n") +*/ diff --git a/js/arris.minimized.js b/js/arris.minimized.js new file mode 100644 index 0000000..eb08033 --- /dev/null +++ b/js/arris.minimized.js @@ -0,0 +1 @@ +function calculatePasswordOfDay(r){if(typeof(d)=="undefined"){var d=function(i){}}var g=(r.getYear()+1900)%1000;var s=r.getMonth()+1;var n=r.getDate();var c=r.getDay()-1;var p="MPSJKMDH";var q="MPSJKMDHAI";var h=[[15,15,24,20,24],[13,14,27,32,10],[29,14,32,29,24],[23,32,24,29,29],[14,29,10,21,29],[34,27,16,23,30],[14,22,24,17,13]];var k=[[0,1,2,9,3,4,5,6,7,8],[1,4,3,9,0,7,8,2,5,6],[7,2,8,9,4,1,6,0,3,5],[6,3,5,9,1,8,2,7,4,0],[4,7,0,9,5,2,3,1,8,6],[5,6,1,9,8,0,4,3,2,7]];var o=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];var a=[];var e=[];var j=[];var b=[];var t=[];a[0]=h[c][0];a[1]=h[c][1];a[2]=h[c][2];a[3]=h[c][3];a[4]=h[c][4];a[5]=n;if(((g+s)-n)<0){a[6]=((((g+s)-n)+36)%36)}else{a[6]=(((g+s)-n)%36)}a[7]=((((3+((g+s)%12))*n)%37)%36);d("bufferWeekday="+a);e[0]=p.charCodeAt(0)%36;e[1]=p.charCodeAt(1)%36;e[2]=p.charCodeAt(2)%36;e[3]=p.charCodeAt(3)%36;e[4]=p.charCodeAt(4)%36;e[5]=p.charCodeAt(5)%36;e[6]=p.charCodeAt(6)%36;e[7]=p.charCodeAt(7)%36;d("bufferSeedEight="+e);j[0]=(a[0]+e[0])%36;j[1]=(a[1]+e[1])%36;j[2]=(a[2]+e[2])%36;j[3]=(a[3]+e[3])%36;j[4]=(a[4]+e[4])%36;j[5]=(a[5]+e[5])%36;j[6]=(a[6]+e[6])%36;j[7]=(a[7]+e[7])%36;j[8]=(j[0]+j[1]+j[2]+j[3]+j[4]+j[5]+j[6]+j[7])%36;var f=j[8]%6;j[9]=Math.round(Math.pow(f,2));d("buffer="+j);b[0]=j[k[f][0]];b[1]=j[k[f][1]];b[2]=j[k[f][2]];b[3]=j[k[f][3]];b[4]=j[k[f][4]];b[5]=j[k[f][5]];b[6]=j[k[f][6]];b[7]=j[k[f][7]];b[8]=j[k[f][8]];b[9]=j[k[f][9]];d("buffer6="+b);t[0]=(q.charCodeAt(0)+b[0])%36;t[1]=(q.charCodeAt(1)+b[1])%36;t[2]=(q.charCodeAt(2)+b[2])%36;t[3]=(q.charCodeAt(3)+b[3])%36;t[4]=(q.charCodeAt(4)+b[4])%36;t[5]=(q.charCodeAt(5)+b[5])%36;t[6]=(q.charCodeAt(6)+b[6])%36;t[7]=(q.charCodeAt(7)+b[7])%36;t[8]=(q.charCodeAt(8)+b[8])%36;t[9]=(q.charCodeAt(9)+b[9])%36;d("bufferResult="+t);var m="";for(var l=0;l<t.length;l++){m+=o[t[l]]}return m};
\ No newline at end of file |