diff options
-rw-r--r-- | js/arris.js | 69 |
1 files changed, 35 insertions, 34 deletions
diff --git a/js/arris.js b/js/arris.js index f52e898..228b54e 100644 --- a/js/arris.js +++ b/js/arris.js @@ -2,7 +2,7 @@ var sys = require("sys") function log(x) { - sys.print("" + x + "\n"); + sys.print("" + x + "\n") } */ @@ -11,10 +11,11 @@ function calculatePasswordOfDay(date) { var log = function(msg) { } } - var year = (date.getYear()+1900) % 1000; - var month = date.getMonth()+1; - var day = date.getDate(); - var weekday = date.getDay()-1; + var year = (date.getYear()+1900) % 1000 + var month = date.getMonth()+1 + var day = date.getDate() + var weekday = ( date.getDay() - 1 + 7 ) % 7; + console.debug(weekday) var seedeight = "MPSJKMDH" var seedten = "MPSJKMDHAI" @@ -48,28 +49,28 @@ function calculatePasswordOfDay(date) { var buffer6 = [] var bufferResult = [] - bufferWeekday[0] = sboxWeekday[weekday][0]; - bufferWeekday[1] = sboxWeekday[weekday][1]; - bufferWeekday[2] = sboxWeekday[weekday][2]; - bufferWeekday[3] = sboxWeekday[weekday][3]; - bufferWeekday[4] = sboxWeekday[weekday][4]; - bufferWeekday[5] = day; + bufferWeekday[0] = sboxWeekday[weekday][0] + bufferWeekday[1] = sboxWeekday[weekday][1] + bufferWeekday[2] = sboxWeekday[weekday][2] + bufferWeekday[3] = sboxWeekday[weekday][3] + bufferWeekday[4] = sboxWeekday[weekday][4] + bufferWeekday[5] = day if (((year + month) - day) < 0) { - bufferWeekday[6] = ((((year + month) - day) + 0x24) % 0x24); + bufferWeekday[6] = ((((year + month) - day) + 0x24) % 0x24) } else { - bufferWeekday[6] = (((year + month) - day) % 0x24); + bufferWeekday[6] = (((year + month) - day) % 0x24) } - bufferWeekday[7] = ((((3 + ((year + month) % 12)) * day) % 0x25) % 0x24); + bufferWeekday[7] = ((((3 + ((year + month) % 12)) * day) % 0x25) % 0x24) log("bufferWeekday=" + bufferWeekday) - bufferSeedEight[0] = seedeight.charCodeAt(0) % 0x24; - bufferSeedEight[1] = seedeight.charCodeAt(1) % 0x24; - bufferSeedEight[2] = seedeight.charCodeAt(2) % 0x24; - bufferSeedEight[3] = seedeight.charCodeAt(3) % 0x24; - bufferSeedEight[4] = seedeight.charCodeAt(4) % 0x24; - bufferSeedEight[5] = seedeight.charCodeAt(5) % 0x24; - bufferSeedEight[6] = seedeight.charCodeAt(6) % 0x24; - bufferSeedEight[7] = seedeight.charCodeAt(7) % 0x24; + bufferSeedEight[0] = seedeight.charCodeAt(0) % 0x24 + bufferSeedEight[1] = seedeight.charCodeAt(1) % 0x24 + bufferSeedEight[2] = seedeight.charCodeAt(2) % 0x24 + bufferSeedEight[3] = seedeight.charCodeAt(3) % 0x24 + bufferSeedEight[4] = seedeight.charCodeAt(4) % 0x24 + bufferSeedEight[5] = seedeight.charCodeAt(5) % 0x24 + bufferSeedEight[6] = seedeight.charCodeAt(6) % 0x24 + bufferSeedEight[7] = seedeight.charCodeAt(7) % 0x24 log("bufferSeedEight=" + bufferSeedEight) buffer[0] = (bufferWeekday[0] + bufferSeedEight[0]) % 0x24 @@ -97,23 +98,23 @@ function calculatePasswordOfDay(date) { 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 = ""; + var out = "" for (var i = 0; i < bufferResult.length; i++) { out += sboxResult[ bufferResult[i] ] } - return out; + return out } /* |