»
EnglishFrenchVietnamese

Print - Encrypt Alphabet Characters - JavaScriptBank.com

Full version: jsB@nk » Security » Encryption » Encrypt Alphabet Characters
URL: https://www.javascriptbank.com/encrypt-alphabet-characters.html

Encrypt Alphabet Characters © JavaScriptBank.comThis is a simple message encoding script. You can encode your message and send it to a friend. He can then decode it using this JavaScript. You can also use the script to encrypt your text files. Numbers and special characters are not allowed.

Full version: jsB@nk » Security » Encryption » Encrypt Alphabet Characters
URL: https://www.javascriptbank.com/encrypt-alphabet-characters.html



CSS
<style type="text/css"><!--.smaller {  font-size: .7em;}--></style><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


JavaScript
<script type="text/javascript"><!-- Begin//Created by: Kaushal K. Prasad :: http://www.geocities.com/mekaushal///*** THIS IS A HELP MESSAGE FUNCTION AND MUST NOT BE CHANGED ***function help() {  var m1,m2,m3,m4,m5,h;  h="                __________ Encoder - Decoder Help __________\n\n";  m1="1) Enter text in the top text area."  m2="2) Press [ Encode ] button to encode it. Encoded text will appear in the middle text area."  m3="3) Copy the encoded text and send/mail it to your friend."  m4="4) He must enter the encoded text in the bottom text area and press [Decode] to see original message."  m5="5) He can use the same method to send/mail any message to you."  alert(h+m1+"\n"+m2+"\n"+m3+"\n"+m4+"\n"+m5);}//*** HELP MESSAGE FUNCTION ENDS HERE ***//var i,j;var getc;var len;var num,alpha;num=new Array("01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","00","##","$$");/* BE CAREFUL, ADD NEW ITEM OF ONLY TWO CHARACTERS IN THE ARRAY ABOVEYOU CAN CHANGE THE ITEMS ABOVE ACCORDINGLY YOURSELF,BUT EACH ITEM SHOULD OF TWO CHARACTERS ONLY */alpha=new Array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"," ",".",",");//********** ENCODER FUNCTION STARTS HERE ***********function encode() {  len=document.f1.ta1.value.length;  document.f1.ta2.value="";  for(i=0;i<len;i++) {    getc=document.f1.ta1.value.charAt(i);    getc=getc.toLowerCase();    for(j=0;j<alpha.length;j++) {      if(alpha[j]==getc) {        document.f1.ta2.value+=num[j];      }    }  }}//*******ENCODER FUNCTION ENDS HERE*******//********* DECODER FUNCTION STARTS HERE *********function decode() {  len=document.f1.ta2.value.length;  document.f1.ta3.value="";  for(i=0;i<len;i++) {    getc=document.f1.ta2.value.charAt(i)+document.f1.ta2.value.charAt(i+1);    i=i+1;    for(j=0;j<num.length;j++) {      if(num[j]==getc) {        document.f1.ta3.value+=alpha[j];      }    }  }}//******* DECODER FUNCTION ENDS HERE *******// End --></script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<BODY onload="javascript:document.f1.ta1.select();"><form name="f1">Enter the text to be encoded below<br><span class="smaller">(Numbers and special characters not allowed )</span><br><textarea cols="35" rows="5" name="ta1"></textarea><br><input type="button" name="b1" value=" Encode " onclick="encode();">    <input type="reset" value=" Reset "><br><br>Encoded text is below<br><textarea cols="35" rows="5" name="ta2" readonly></textarea><br><input type=button value="Highlight All" onClick="javascript:this.form.ta2.focus();this.form.ta2.select();"> <span class="smaller">... then click CTRL+c</span><br><br>Enter the text to be decoded below<br><textarea cols="35" rows="5" name="ta3"></textarea><br><input type="button" name="b1" value=" Decode " onclick="decode();">    <input type="reset" value=" Reset "><br><br><span class="smaller"><a href="http://www.geocities.com/mekaushal/">Kaushal K. Prasad</a>  ::  <a href="javascript:help();">Click for Help!</a></span></form></body><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->