Skip to content

Instantly share code, notes, and snippets.

@alfredmyers
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alfredmyers/5cc3b9e4aa97bf9d20da to your computer and use it in GitHub Desktop.
Save alfredmyers/5cc3b9e4aa97bf9d20da to your computer and use it in GitHub Desktop.
Google for Work Security Key Challenge
<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