I am trying to replace multiple string values at once from one variable and pass it into a new one from form data.
My final outcome is to make a very simple (and crude) encrypt\decrypt program.
This is what I have so far. I can’t seem to find anything on where to go from here.
function testResults (form) {
var TestVar = form.inputbox.value;
var NewVar = TestVar.replace(/a/g, "b").replace(/b/g, "c");
alert ("Replaced text: " + NewVar);
}
I do not think a regex is the right way to go for an obfuscation algorithm. You should manipulate the strings with your own code algorithm, not with a regex. Here’s a simple way to bump up every character in the string by one value like you were trying to do with the regex:
You can see an example here: http://jsfiddle.net/jfriend00/LYnAV/.
FYI, please don’t call this encryption as it is not encryption. It’s obscuration (obscuring the original value in a non-secure fashion).