Created
December 29, 2022 23:27
-
-
Save sean3z/d6363b6becfd3776112a49f689761571 to your computer and use it in GitHub Desktop.
WOL Apgar routine in Javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function apgar(s) { | |
if (s.length != 8) return false; | |
var s = s.split(''), o = []; | |
var u = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./'; | |
for(var i = 0; i <= 7; i++) { | |
var a = s[(8 - i)], r = ((i == 0) ? 0 : a.charCodeAt(0)); | |
var j = s[i].charCodeAt(0), x = ((j & 1) ? (j << 1) & r : j ^ r); | |
var k = (x & 0x3f), f = u.substring(k, (k + 1)); | |
o.push(f); | |
} | |
return o.join(''); | |
} | |
console.log('apgar', apgar('password')); // WaIMMsbf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment