Pengamanan File Citra Dengan Skema Hybrid Cryptosystem Menggunakan Algoritma RSA-CRT Dan Algoritma Affine Cipher

A-1

LISTING PROGRAM

Form Pembangkit Kunci
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
namespace affine_cipher_dan_rsa_crt
{
///
/// Description of Pembangkit_kunci.
///
public partial class Pembangkit_kunci : Form
{
int p,q,n,totien,dp,dq;
double qinv;
//


List d22 = new List();

//

List d11 = new List();
Random r = new Random();
public Pembangkit_kunci()
{
//
// The InitializeComponent() call is required for Windows

Forms designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the
InitializeComponent() call.
//
}
void GroupBox1Enter(object sender, EventArgs e)

{

Universitas Sumatera Utara

A-2

}
void HomeToolStripMenuItemClick(object sender, EventArgs e)
{
MainForm pilih = new MainForm();
pilih.Show();
this.Hide();
}
void EnkripsiToolStripMenuItemClick(object sender, EventArgs
e)
{
ENKRIPSI pilih = new ENKRIPSI();
pilih.Show();
this.Hide();
}

void DekripsiToolStripMenuItemClick(object sender, EventArgs
e)
{
Dekripsi pilih = new Dekripsi();
pilih.Show();
this.Hide();
}
public int GCD(int a, int b)
{
int Remainder;
while( b != 0 )
{
Remainder = a % b;
a = b;
b = Remainder;
}
return a;
}
public UInt64 sma(UInt64 x, UInt64 H, UInt64 n)
{

UInt64 r;

Universitas Sumatera Utara

A-3

int[] bin = new int[32];
int i;
r = x;
i = 0;
/* ubah H ke Biner */
while( H > 0 )
{
if (H % 2 == 0)
{
bin[i] = 0;
}
else
{
bin[i] = 1;

}
H = H/2;
i++;
}
i--;
while(i>0)
{
r = (r * r) % n;
if( bin[--i] == 1 )
{
r = (r * x) % n;
}
}
return r;
}
public int lehmann(int n)
{
int a = 0,i = 0;
UInt64 l;
for(i=1;i