SOURCE

// 加密字符串
function caesarCipherEncrypt(text, shift) {
    return text.split('').map(char => {
        var code = char.charCodeAt(0);
        if (code>96 && code<123) {
            code = (code - 97 + shift) % 26 + 97;
        } else if (code>64 && code<91) {
            code = (code - 65 + shift) % 26 + 65;
        }
        if(code>32 && code<127){
            code = (code - 33 + shift ) % 94 + 33;
        }
        return String.fromCharCode(code);
    }).join('');
}

// 解密字符串
function caesarCipherDecrypt(text, shift) {
    return text.split('').map(char => {
        var code = char.charCodeAt(0);
        if(code>32 && code<127){
            code = (code - 33 - shift + 94) % 94 + 33;
        }
        if (code>96 && code<123) {
            code = (code - 97 - shift + 26) % 26 + 97;
        } else if (code>64 && code<91) {
            code = (code - 65 - shift + 26) % 26 + 65;
        }
        return String.fromCharCode(code);
    }).join('');
}

var key = '0474014ef930d8b4ba957feba022913b';
var num = 9;       

var aa = caesarCipherEncrypt( key , num);
var bb = caesarCipherDecrypt(aa,num);

var keyj = num + aa;

console.log( aa );
console.log( bb );
console.log( keyj );
console 命令行工具 X clear

                    
>
console