»
EnglishFrenchVietnamese

Print - Character Encoder - JavaScriptBank.com

Full version: jsB@nk » Security » Encryption » Character Encoder
URL: https://www.javascriptbank.com/character-encoder.html

Character Encoder © JavaScriptBank.comEnccode messages. Use it to communiate with your friends in secrecy.

Full version: jsB@nk » Security » Encryption » Character Encoder
URL: https://www.javascriptbank.com/character-encoder.html



JavaScript
<script>function doextract() {// get the code from the uservar code = document.code.code.value// make the code lowercasecode.toLowerCase()// create an array of maximum charactersvar char = new Array(16)// create an array of maximum encrypted charactersvar encryptchar = new Array(16)//create a place to store the encrypted stringvar encrypt = ""/*    create a loop to place the characters of the code into the array   the first character is placed in char[0], the 16 characters in   char[15].*/for(var i=0;i<code.length;i++) {// extract the character at position, ichar[i] = code.charAt(i)// run the encryptor of that character and store it in an arrayencryptchar[i] = runencrypt(char[i])}// run a loop to concatenate all the array membersfor(var j=0;j<code.length;j++) {//store the encrypted characters as a stringencrypt = ""+ encrypt +""+ encryptchar[j] +""}// give the encrypted code to the userdocument.code.string.value = encrypt// prevent the submission from occurringreturn false;}function runencrypt(char) {// create a variable to store the encrypt valuevar encrypt;// create a variable to mess around with the ASCII valuevar ASCIImess// create a loop searching for the ASCII value of the charfor (var i=0;i<256;i++) {// convert i into a 2-digit hex stringvar ASCII = i . toString (16);if (ASCII.length == 1)ASCII = "0" + ASCII;// insert a % character into the stringASCII = "%" + ASCII;// determine the character represented by the escape codeASCII = unescape (ASCII);// if the characters match, we've found the ASCII valueif (ASCII == char)break;}// store the ASCII value for backupASCIImess = i// subtract 34 to the ASCII valueASCIImess = eval(ASCIImess - 34)// make sure the value is not less than 0if(ASCIImess < 0) {// make the number positiveASCIImess = eval(ASCIImess * -1)}// multiply by the value of 3ASCIImess = eval(ASCIImess * 3)// make sure the ASCII is not greater than 255 (greatest possible is 663)if(ASCIImess > 255) {// make the difference the new valueASCIImess = eval(ASCIImess - 255)}// check a second time (greatest possible is 408)if(ASCIImess > 255) {// make the difference the new valueASCIImess = eval(ASCIImess - 255)}// add 12 to the ASCII value (greatest val is 255)ASCIImess = eval(ASCIImess - -12)// make sure tha ASCII value is under 255 (greatest possible is 420)if(ASCIImess > 255) {// make the difference the new valueASCIImess = eval(ASCIImess - 255)}// make a final checkif(ASCIImess > 255 || ASCIImess < 0) {// make the value 56ASCIImess = eval(56)}// convert the ASCII value to a characterencrypt = String.fromCharCode(ASCIImess)// return the new value to the encryptchar valuereturn encrypt;}</script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<form name="code" onsubmit="return doextract()">Type code here: <input name="code" maxlength="16"><br><br><input type="submit" value="Get String!"><br><br><input name="string"></form><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->