Professional Documents
Culture Documents
Plaint P A N G E R A N
ext
Key R A S A R A S A
proses berikutnya, kita ubah key nya jadi index hurufnya, yang
nantinya akan kita tambahkan ke index plaintextnya (A = 0 sampai
dengan Z = 25)
Plaintext P A N G E R A N
Index Plaintext 1 0 1 6 4 1 0 1
5 3 7 3
Key R A S A R A S A
Index Key 1 0 1 0 1 0 1 0
7 8 7 8
(Plaintext + key) 6 0 5 6 2 1 1 1
mod 26 1 7 8 3
Cipher Text G A F G V R S N
Cipher Text G A F G V R S N
Index Plaintext 6 0 5 6 2 1 1 1
1 7 8 3
Key R A S A R A S A
Index Key 1 0 1 0 1 0 1 0
7 8 7 8
(Plaintext - key) 1 0 1 6 4 1 0 1
mod 26 5 3 7 3
Cipher Text P A N G E R A N
1. Enkripsi
2. Dekripsi
html {
background: #63bad8 50% 0px repeat-x;
text-align: center;
}
body {
text-align: center;
font: 12px 'Lucida Grande',lucida,helvetica,arial,sans-serif;
color: #333333;
padding: 0px;
margin: 0 auto;
width: 840px;
}
#wrappertop{
width: 800px;
height: 10px;
padding: 0 20px 0 20px;
margin-top: 10px;
}
#wrapperbottom{
width: 800px;
height: 10px;
padding: 0 20px 0 20px;
margin-bottom: 10px;
}
#wrapper{
width: 800px;
padding: 0 20px 0 20px;
position: relative;
}
#content{
width: 800px;
background-color: #fff;
text-align: left;
}
#darkbannerwrap{
background: url(../images/aiwrap.png);
width: 18px;
height: 10px;
margin: 0 0 20px -18px;
position: relative;
}
#header {
width: 780px;
background: #c5e6ea;
padding: 15px 0 15px 20px;
border-bottom: #b2ccd0 solid 1px;
text-align: center;
}
#result_layout {
color: #00529B;
width: 450px;
background: #c5e6ea;
padding: 15px;
border-bottom: #b2ccd0 solid 1px;
text-align: center;
position: relative;
top: 50px;
margin-left: 20px;
visibility: hidden;
}
h1{
margin-top: 15px;
display: inline;
width: 220px;
font: 16px 'Lucida Grande', arial, sans-serif;
font-weight: bold;
}
body#login {
width: 475px;
}
body#login #wrapper{
width: 370px;
padding: 0 20px 0 20px;
}
body#login #content{
width: 370px;
}
body#login #header {
width: 450px;
}
body#login fieldset{
width: 430px;
border: 0;
margin: 0px;
display: block;
margin-top: -30px;
background-color: #fff;
padding-top: 20px;
}
body#login label{
float: left;
text-align: left;
width: 70px;
font-weight: bold;
margin-right: 10px;
padding-top: 7px;
}
body#login input{
height: 20px;
width: 150px;
margin-bottom: 15px;
padding: 3px;
font: 12px 'Lucida Grande', arial, sans-serif;
}
body#login .form button{
display:block;
float:left;
margin:0 3px 0 80px;
margin-left: 175px;
}
fieldset{
background-color: #eaf6f7;
border-top: 2px solid #acdbe1;
border-bottom: 2px solid #acdbe1;
margin: 20px;
padding: 20px;
display: block;
*position: relative;
*margin-top:20px;
*padding-top:40px;
}
label{
float: left;
text-align: left;
width: 150px;
font-weight: bold;
margin-right: 10px;
padding-top: 7px;
}
input{
height: 20px;
width: 300px;
margin-bottom: 15px;
padding: 3px;
font: 12px 'Lucida Grande', arial, sans-serif;
}
select{
height: 30px;
width: 120px;
margin-bottom: 15px;
padding: 3px;
font: 12px 'Lucida Grande', arial, sans-serif;
}
textarea{
height: 100px;
width: 300px; margin-bottom: 15px;
padding: 3px;
font: 12px 'Lucida Grande', arial, sans-serif;
}
.form button{
display:block;
float:left;
margin:0 7px 0 160px;
background-color:#92c97c;
border:1px solid #73b35a;
font-family:"Lucida Grande", Tahoma, Arial, Verdana, sans-serif;
font-size:100%;
line-height:130%;
text-decoration:none;
font-weight:bold;
color:#e8f7df;
cursor:pointer;
padding:5px 10px 6px 7px; /* Links */
}
.form button{
width:auto;
overflow:visible;
padding:4px 10px 3px 7px; /* IE6 */
}
.form button[type]{
padding:5px 10px 5px 7px; /* Firefox */
line-height:17px; /* Safari */
}
*:first-child+html button[type]{
padding:4px 10px 3px 7px; /* IE7 */
}
.form button img, .buttons a img{
margin:0 6px -3px 0 !important;
padding:0;
border:none;
width:16px;
height:16px;
text-decoration: none;
}
button:hover{
background-color:#e8f7df;
border:1px solid #92c97c;
color:#31940c;
}
.buttons a:active{
background-color:#e8f7df;
border:1px solid #92c97c;
color:#31940c;
}
-->
</style>
<script language='Javascript'>
function disableEnter(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ?
evt.srcElement : null);
if ((evt.keyCode == 13) && (node.type=="text")) {return false;}
}
document.onkeypress = disableEnter;
// Validate key:
key = key.toUpperCase();
var key_len;
var i;
var adjusted_key = "";
var key_char;
for (i=0; i<key.length; i++)
{
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 output = "";
var key_index = 0;
var in_tag = false;
for (i=0; i<input.length; i++)
{
if ( input[i] == " " )
{
continue;
}
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 (mode=='1')
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 processData()
{
var plainText = document.getElementById('p_text').value;
var key = document.getElementById('key').value;
var mode = document.getElementById('mode').value;
document.getElementById('result_layout').style.visibility='visible';
document.getElementById('result_layout').innerHTML=hasil;
}
</script>
</head>
<body id="login">
<div id="wrappertop"></div>
<div id="wrapper">
<div id="content">
<div id="header">
<h1>Vigenere Cipher</h1>
</div>
<div id="darkbannerwrap"> </div>
<form name="form1" method="post">
<fieldset class="form">
<p><label for="p_text">Teks</label><textarea
id="p_text"></textarea></p>
<p><label for="key">Kata Kunci</label><input name="key" id="key"
type="text"></p>
<p><label for="mode">Mode</label>
<select name="mode" id="mode">
<option value="1" selected>Encrypting</option>
<option value="2">Decrypting</option>
</select>
</p>
<button type="button" class="positive" name="btn_process"
id="btn_process" onClick="processData();" value="Process">
Process</button>
</fieldset>
</form>
</div>
</div>
<div id="result_layout"></div>
</body>
</html>