Екатерина13,
<script>
function crypt(message, key, decrypt) {
var a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");
message = message.split("");
key = ("" + key).split("");
return message.reduce(function(message, current) {
var i = a.indexOf(current),
b = +key.shift();
key.push(b);
decrypt ? (i -= b, i < 0 && (i += a.length)) : (i += b, i %= a.length);
return message + a[i]
}, "")
};
document.write(crypt("RAMMSTEIN", 2015)+"<br>") // encrypt
document.write(crypt("TANRUTFNP", 2015, true)) // decrypt
</script>