Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
regexp callback solution in Clear category for [old] Caesar Cipher (decryptor) by vincent.tscherter
"use strict";
function toDecrypt(cryptotext, delta) {
return cryptotext.replace(/[^a-z ]/g, '').replace(/[a-z]/g, a =>
String.fromCharCode(97 + (a.charCodeAt(0) - 71 + delta) % 26));
}
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!");
}
May 24, 2018
Comments: