LISTING PROGRAM
void ENKRIPSIToolStripMenuItemClick(object sender, Eve
ntArgs e)
void DEKRIPSIToolStripMenuItemClick(object sender, Eve
ntArgs e) {
Dekripsi dekrip = new Dekripsi();
dekrip.n = n;
keluar dari Aplikasi?","konfirmasi",
2.
Enkripsi plainteks menggunakan Algoritma ADFGVX
Cipher
string[] arrkunci1= new string[] {"A", "D", "F", "G", "V", "X"}; string[,] arrkunci2
= new string[6,6] {{"F","E","D","C","B","A"}, {"G","H","I","J"," K","L"}, {"R","Q","P","O","N","M"}, {"S","T","U","V","W","X"}, { "3","2","1","0","Z","Y"}, {"4","5","6","7","8","9"}};
string tekss = richTextBox1.Text.ToUpper().ToString(); char[] teks = tekss.ToCharArray();
string[] cipher = new string[10000]; nteks = tekss.Length;
int l = 0;
Stopwatch timer = new Stopwatch();
timer.Start();
Convert.ToDouble(l)/Convert.ToDouble(textBox3.TextLength);
char[] txtkunci = textBox3.Text.ToUpper().ToCharArray(); barkey = (Convert.ToInt16( Math.Ceiling(n)))+2;
else{
char[] tempkey = new char[kolkey]; char[] tempkey1 = new char[10000];
for (int i=0; i<kolkey; i++){
textBox2.Text = timer.Elapsed.TotalSeconds.ToString();
3.
Acak Kunci Algoritma
Knapsack
public int gcd(int p2, int n2){
return p2; }
return gcd(n2, p2 % n2); }
public bool iscoprime(int p1, int n1){
if (gcd(p1, n1) == 1){
return true;
}
return false;
}
void Button4Click(object sender, EventArgs e)
{
char[] txtkunci = textBox5.Text.ToCharArray(); string tempbiner;
char[] biner = new char[nW]; nW = textBox3.TextLength;
Stopwatch timer = new Stopwatch();
timer.Start();
5.
Dekripsi cipherkey menggunakan Algoritma
Knapsack
int invmodulo = Convert.ToInt16(textBox4.Text); string plainkey = "";
Stopwatch timer = new Stopwatch();
timer.Start();
for (int i=0; i<n; i++){
tempplain = (cipherkunci[i]*invmodulo) % bilm;
for (int j=6; j>=0; j--){
textBox5.Text += (char)Convert.ToInt16(plainkey,2); }
timer.Stop();
6.
Dekripsi Cipherteks Menggunakan Algoritma ADFGVX
Cipher
string[] arrkunci1= new string[] {"A", "D", "F", "G", "V", "X"}; string[,] arrkunci2
= new string[6,6] {{"F","E","D","C","B","A"}, {"G","H","I","J" ,"K","L"},{"R","Q","P","O","N","M"}, {"S","T","U","V","W","X"} , {"3","2","1","0","Z","Y"}, {"4","5","6","7","8","9"}}; char[] tempkey = textBox5.Text.ToUpper().ToCharArray(); char[] tempkey1 = new char[1000];
string tempplainteks="";
Stopwatch timer = new Stopwatch();
timer.Start();
char[] tempplainteks1 = tempplainteks.ToCharArray(); int x = 0;
while (x<textBox7.TextLength){
if (char.IsLetter(tempplainteks1[x]) == true && temppl
ainteks1[x] != 'x'){
textBox8.Text +=arrkunci2[Array.IndexOf(arrkunci1, (te mpplainteks1[x]).ToString()), Array.IndexOf(arrkunci1, (temppl ainteks1[x+1].ToString()))];
x+=2; }
break; }
else{
textBox8.Text += tempplainteks1[x].ToString(); x+=1;
} }
timer.Stop();