I have made a small script for encrypting data. Now I'm wondering how efficient it is for normal users who aren't programmers and for people who are programmers.
I mean if you don't have this script there is no way to find out what the text is right?
function cipher(message, action) {
var text = message;
var encrypted = "";
for(var i = 0; i < text.length; i++) {
var ASCII = text[i].charCodeAt(0);
var n = null;
if(i % 2 == 0) {
n = action == 'encrypt' ? ASCII + 4 : ASCII - 4;
}
else if(i % 2 == 1) {
n = action == 'encrypt' ? ASCII + 7 : ASCII - 7;
}
var s = String.fromCharCode(n);
encrypted += s;;
}
return encrypted;
}
console.log(cipher("Hello World", 'encrypt'))
If you were to make it more secure, what would you add? I was thinking of a complete custom random mapping for each letter but retrieving it after decryption is something I can't figure out yet.