Here's the code for the encryption. First every second letter is set and then every other letter(input: abcdefgh; output: acegdfh). I can't figure out the decryption. I figured, seperating the encrypted text in two and alternately taking a letter from each would work. Any ideas for the code?
onEvent("button_encrypt", "click", function(encrypt) {
var text = getText("text_input1");
var encripted = "";
var i = 0;
while ((i < klartext.length)) {
encrypted = encrypted + text.charAt(i);
i = i + 2;
}
i = 1;
while ((i < text.length)) {
encrypted = encrypted + text.charAt(i);
i = i + 2;
}
setText("text_input1", encrypted);
});
I like this encryption style. I mocked up the solution in a Code.org app for testing and such.
Encrypt First I cleaned up the encryption code a little. I found a couple variable names that got off slightly.
Decryption I tackled decryption by taking the encrypted data, splitting it in half, then pealing the front letter off each half, alternating back and forth.