Inside the internet - Security rot code
A rot display for a given input
by ledlogic
HTML
<input id="secret" value="upbtu" />
<button onclick="doDecode()">decode</button>
<ul id="results"></ul>
CSS
ul, li {
font-family: Helvetica, Arial;
font-size: 0.9em;
}
textarea {
height: 500px;
width: 80%;
margin-left: 10%;
}
JavaScript
function doDecode() {
var secret = $("#secret").val();
for (var i = 0; i < 26; i++) {
var d = rot(secret, i);
$("#results").append("<li>" + i + ":" + d + "</li>");
}
}
function rot(s, i) {
// modified for general rot# from
// http://stackoverflow.com/a/617685/987044
return s.replace(/[a-zA-Z]/g, function (c) {
return String.fromCharCode((c <= "Z" ? 90 : 122) >= (c = c.charCodeAt(0) + i) ? c : c - 26);
});
}