Last active
August 29, 2015 14:24
-
-
Save alfredmyers/5cc3b9e4aa97bf9d20da to your computer and use it in GitHub Desktop.
Google for Work Security Key Challenge
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
<html> | |
<head> | |
<script type='text/javascript'> | |
function decypher() { | |
var om = document.getElementById('orig_message').value; | |
var msg = ''; | |
var cypher = -3; | |
for (i = 0; i < om.length; i++) { | |
var ascii = om.charCodeAt(i); | |
var delta = 0; | |
var a; | |
if (ascii > 64 && ascii < 91) { | |
delta = 64; | |
} | |
else if (ascii > 96 && ascii < 123) { | |
delta = 96; | |
} | |
a = ascii - delta; | |
if (delta != 0) { | |
a += cypher; | |
if (a < 1) { | |
a += 26; | |
} | |
} | |
msg += String.fromCharCode(a + delta); | |
} | |
document.getElementById('decyphered').value = msg; | |
} | |
</script> | |
</head> | |
<body> | |
<textarea id='orig_message' rows="4" cols="50"> | |
Wuhdw brxu sdvvzrug olnh brxu wrrwkeuxvk. | |
Grq'w ohw dqbergb hovh xvh lw, dqg jhw d | |
qhz rqh hyhub vla prqwkv. Foliirug Vwroo | |
</textarea> | |
<br/> | |
<input type="button" onclick="decypher();" value="Decypher"/> | |
<br/> | |
<textarea id='decyphered' rows="4" cols="50"></textarea> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment