Feb 13, 2011

Home » » program enkripsi vigenere cipher dengan html

program enkripsi vigenere cipher dengan html

buat agan yang lagi mempelajari enkripsi, saya punya program yang saya dapat dari internet... nih dia silakan copy kode di bawah, terus paste di dalam teks editor seperti notepad, simpan dengan ekstensi html..


kode program


<html>

  <head>

    <title>Vignere Cipher</title>

    <!--

      CryptoMX Tools

      Copyright (C) 2004 - 2006 Derek Buitenhuis



      This program is free software; you can redistribute it and/or

      modify it under the terms of the GNU General Public License

      as published by the Free Software Foundation; either version 2

      of the License, or (at your option) any later version.



      This program is distributed in the hope that it will be useful,

      but WITHOUT ANY WARRANTY; without even the implied warranty of

      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

      GNU General Public License for more details.



      You should have received a copy of the GNU General Public License

      along with this program; if not, write to the Free Software

      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

    -->

  </head>

  <body bgcolor=#FFFFFF text=#000000>

    <td>

      <script>

function Vigenere (input, key, forward)

{

  if (key == null)

    key = "";

  var alphabet =   "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

                 + "abcdefghijklmnopqrstuvwxyz";



  // Validate key:

  key = key . toUpperCase ();

  var key_len = key . length;

  var i;

  var adjusted_key = "";

  for (i = 0; i < key_len; i ++)

  {

    var key_char = alphabet . indexOf (key . charAt (i));

    if (key_char < 0)

      continue;

    adjusted_key += alphabet . charAt (key_char);

  }

  key = adjusted_key;

  key_len = key . length;

  if (key_len == 0)

  {

    alert ('You forgot to supply a key!');

    key = "a";

    key_len = 1;

  }



  // Transform input:

  var input_len = input . length;

  var output = "";

  var key_index = 0;

  var in_tag = false;

  for (i = 0; i < input_len; i ++)

  {

    var input_char = input . charAt (i);

    if (input_char == "<")

      in_tag = true;

    else if (input_char == ">")

      in_tag = false;

    if (in_tag)

    {

      output += input_char;

      continue;

    }

    var input_char_value = alphabet . indexOf (input_char);

    if (input_char_value < 0)

    {

      output += input_char;

      continue;

    }

    var lowercase = input_char_value >= 26 ? true : false;

    if (forward)

      input_char_value += alphabet . indexOf (key . charAt (key_index));

    else

      input_char_value -= alphabet . indexOf (key . charAt (key_index));

    input_char_value += 26;

    if (lowercase)

      input_char_value = input_char_value % 26 + 26;

    else

      input_char_value %= 26;

    output += alphabet . charAt (input_char_value);

    key_index = (key_index + 1) % key_len;



  }

  return output;

}



function runcoder (dir)

{

  document . form . output . value = Vigenere (document . form . input . value, document . form . key . value, dir);

/*  A bug in IE prevents this section from working correctly.

  with (document . form)

  {

    output . value = Vigenere (input . value, key . value, dir);

  }

*/

}

    </script>

    <form name=form>

      <table border cellspacing="2">

        <tr>

          <td>

            Input:<br>

            <input type=button onClick="this.form.input.value='';" value="clear">

          </td>

          <td>

            <textarea name=input rows=10 cols=60 wrap=virtual></textarea>

          </td>

        </tr>

        <tr>

          <td>

            Key:<br>

            <input type=button onClick="this.form.key.value='';" value="clear">

          </td>

          <td>

            <textarea name=key rows=5 cols=60 wrap=virtual></textarea>

          </td>

        </tr>

        <tr>

          <td>Coding direction:</td>

          <td>

            <input type=button value="encode" onClick="runcoder (true);">

            <input type=button value="decode" onClick="runcoder (false);">

          </td>

        </tr>

          <td>

            Output:<br>

            <input type=button onClick="this.form.output.value='';" value="clear">

          </td>

          <td>

            <textarea name=output rows=10 cols=60 wrap=virtual></textarea>

          </td>

        </table>

      </form>

  </body>

</html>



Artikel yang Berkaitan :

7 comments:

Anonymous said...

mantap gan...

Yuri Rahmanto said...

Bagus gan , bisa diberi penjelasan tiap script yang ada ga gan ? ane bingung,, hehe ,, makasih,,

Anonymous said...

bagi ya...

hanum said...

terkait dengan penerapan enkripsi, bisa diunduh artikel berikut http://repository.gunadarma.ac.id/bitstream/123456789/2274/1/01-03-010-Penerapan%5BRangga%5D.pdf

Allyn said...

thanks bgt, akan saya pelajari.. moga pahala ngalir trus.. amin.. :)

NAFCOM Pusat Tinta Printer, Toner Laser, Kertas Foto, dan CISS Printer Desktop/LargeFormat said...

saya coba ah scriptnya, moga aja jalan dengan baik

NAFCOM Pusat Tinta Printer, Toner Laser, Kertas Foto, dan CISS Printer Desktop/LargeFormat said...

Makasih bos, mantap ..!!!
Ternyata program Works dengan sempurna. :)

Post a Comment

Para pengunjung yang terhormat, berhubung saya baru belajar, mohon kritik dan saran yang membantu..

silakan tinggalkan komentar...

Protected by Copyscape Online Plagiarism Check