Implementasi Dan Analisis Algoritma Massey-Omura Dan Algoritma Even-Rodeh Dalam Pengamanan Dan Kompresi File Dokumen

LISTING PROGRAM

1.

Class keygen.cs

using System;
using System.Numerics;
namespace Program_Skripsi
{
///
/// Description of keygen.
///
public class keygen
{
private int prima;
public keygen(int p)
{
this.prima = p;
}
public static BigInteger bilprima(BigInteger random){

int counter=0;
for (int i=2; i 0) return 0;
else return random;
}
public static BigInteger gcd(BigInteger m, BigInteger n){
BigInteger r = m % n;
while (r != 0){
return gcd(n,r);
}
return n;
}
public static int kunci_eA(int prima){
Random rnd = new Random();
int key_eA = rnd.Next(2, prima-1);
if (gcd(key_eA,prima-1) == 1)
return key_eA;
else
return kunci_eA(prima);
}
public static int kunci_dA(int prima, BigInteger eA){

int key_dA = 1;
BigInteger hasil = (key_dA*eA) % (prima-1);
while (hasil != 1 && hasil != 0){
key_dA++;

Universitas Sumatera Utara

hasil = (key_dA*eA) % (prima-1);
}
if (hasil == 0 && key_dA!=eA)
return kunci_dA( prima, eA);
else
return key_dA;
}
public static BigInteger kunci_eB(int prima){
Random rnd2 = new Random();
BigInteger key_eB = rnd2.Next(2, prima-1);
if (gcd(key_eB,prima-1)==1 )
return key_eB;
else

return kunci_eB(prima);
}
public static int kunci_dB(int prima, int eA, int dA, BigInte
ger eB){
BigInteger hasil;
int key_dB=1;
if (gcd(eB,prima-1)==1 ){
hasil = (key_dB*eB) % (prima-1);
while (hasil != 1 && hasil != 0){
key_dB++;
hasil = (key_dB*eB) % (prima-1);
}
if (hasil
== 0 && key_dB!=eA && key_dB!=dA && key_dB!=eB)
return kunci_dB(prima, eA, dA, eB);
else
return key_dB;
}
else
return kunci_dB(prima, eA, dA, eB);

}
}
}

2.

Class MO.cs

using
using
using
using

System;
System.Collections.Generic;
System.Text;
System.Numerics;

namespace Program_Skripsi
{

///
/// Description of mo.
///
public class MO
{
private string teks;
public MO(string t)

Universitas Sumatera Utara

{
this.teks = t;
}
public static string enkripsiPlain(string plaintxt, int prima
, int eA){
StringBuilder bitsplain = new StringBuilder();
StringBuilder text = new StringBuilder();
BigInteger c1x;
BigInteger
sum, sum2=1, aaa=0, hasil=0, sumx, sumx2=1;

foreach (char c in plaintxt){
bitsplain.Append(c);
}
BigInteger[] p = new BigInteger[bitsplain.Length];
for (int i=0; i