javascript - Decoding code text to ASCII failure -


my program codes normal text ascii. works well, except decoding doesn't work. wrong?

also, don't want commas appear when coded text printed. oh, , want include caesar cipher too.

function code() {    var leer = document.getelementbyid('1').value,        array = [];    (var = 0; < leer.length; i++) {      array[i] = leer[i].charcodeat(0);    }    document.getelementbyid('2').innerhtml = 'chale, chale ' + array;  }    function decode() {    var leer = document.getelementbyid('1').value,        array = [];    (var = 0, char; char = leer[i]; i++) {      array[i] = string.fromcharcode(leer[i].charcodeat(0));    }    document.getelementbyid('2').innerhtml = 'chale, chale ' + array;  }
<form>    escriba el mensaje:<br><br>    <input type="text" id="1" name="mensaje" rows="10" cols="40">    <br><br>    <br><br> elige una opciĆ³n:    <br><br>    <input type="button" name="cifra" value="cifrar" onclick="code()">    <input type="button" name="decifra" value="decifrar" onclick="decode()">    <br><br>    <textarea id="2" rows="5" cols="40"></textarea>  </form>

you should use string string instead array in decoding function

function decode() { var leer = document.getelementbyid('1').value, str = ""; (var = 0, char; char = leer[i]; i++) {     str += string.fromcharcode(leer[i].charcodeat(0)); } document.getelementbyid('2').innerhtml = 'chale, chale ' + str;} 

Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -