• Web sitemizin içeriğine ve tüm hizmetlerimize erişim sağlamak için Web sitemize kayıt olmalı ya da giriş yapmalısınız. Web sitemize üye olmak tamamen ücretsizdir.
  • Sohbetokey.com ile canlı okey oynamaya ne dersin? Hem sohbet et, hem mobil okey oyna!
  • Soru mu? Sorun mu? ''Bir Sorum Var?'' sistemimiz aktiftir. Paylaşın beraber çözüm üretelim.

Basit Encoder-Decoder (ing)

Üyelik Tarihi
7 Ocak 2015
Konular
4,091
Mesajlar
4,274
MFC Puanı
40
Kod:
<!-- THREE STEPS TO INSTALL SIMPLE ENCODER-DECODER:

  1.  Copy the coding into the HEAD of your HTML ********
  2.  Add the onLoad event handler into the BODY tag
  3.  Put the last coding into the BODY of your HTML ********  -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML ********  -->

<HEAD>

<style type="text/css">
<!--
.smaller {
  font-size: .7em;
}
-->
</style>

<script type="text/javascript">
<!-- Begin
/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
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 ABOVE
YOU 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=********.f1.ta1.value.length;
  ********.f1.ta2.value="";
  for(i=0;i<len;i++) {
    getc=********.f1.ta1.value.charAt(i);
    getc=getc.toLowerCase();
    for(j=0;j<alpha.length;j++) {
      if(alpha[j]==getc) {
        ********.f1.ta2.value+=num[j];
      }
    }
  }
}
//*******ENCODER FUNCTION ENDS HERE*******

//********* DECODER FUNCTION STARTS HERE *********

function decode() {
  len=********.f1.ta2.value.length;
  ********.f1.ta3.value="";
  for(i=0;i<len;i++) {
    getc=********.f1.ta2.value.charAt(i)+********.f1.ta2.value.charAt(i+1);
    i=i+1;
    for(j=0;j<num.length;j++) {
      if(num[j]==getc) {
        ********.f1.ta3.value+=alpha[j];
      }
    }
  }
}
//******* DECODER FUNCTION ENDS HERE *******

// End -->
</script>
</HEAD>

<!-- STEP TWO: Insert the onLoad event handler into your BODY tag  -->

<BODY onload="javascript:********.f1.ta1.select();">

<!-- STEP THREE: Copy this code into the BODY of your HTML ********  -->

<div align="center">
<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>
</div>

<p><center>
<font face="arial, helvetica" size"-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

<!-- Script Size:  4.21 KB -->
 
Üst