Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Clear&Readable solution in Clear category for [old] Caesar Cipher (decryptor) by SaintDron
"use strict";
function toDecrypt(cryptotext, delta) {
const alph = "abcdefghijklmnopqrstuvwxyz".repeat(3);
return cryptotext.replace(/[^a-z ]/ig, '')
.split('')
.map(v => (v === ' ') ? ' ' : alph[alph.indexOf(v, 26) + delta])
.join('');
}
var assert = require('assert');
if (!global.is_checking) {
console.log('Example:')
console.log(toDecrypt('abc', 10))
// These "asserts" are used for self-checking and not for an auto-testing
assert.equal(toDecrypt("!d! [e] &f*", -3), "a b c")
assert.equal(toDecrypt("x^$# y&*( (z):-)", 3), "a b c")
assert.equal(toDecrypt("iycfbu!@# junj%&", -16), "simple text")
assert.equal(toDecrypt("*$#%swzybdkxd !)(^#%dohd", -10), "important text")
assert.equal(toDecrypt("fgngr **&&frperg^__^", 13), "state secret")
console.log("Coding complete? Click 'Check' to earn cool rewards!");
}
Sept. 14, 2018