Implementasi Kriptografi Hybrid Crypto Sistem Algoritma RSA – Naïve Dan Algoritma Zig-Zag Dalam Pengamanan File

71

LISTING PROGRAM

PROSES ENKRIPSI :
/*
* Created by SharpDevelop.
* User: Rahmi Suliani Lubis
* Date: 10/05/2017
* Time: 15.32
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

using System.Windows.Forms;
namespace skripsi_program
{
///
/// Description of MainForm.
///
public partial class MainForm : Form
{
int[] kuncizigzag = new int[8];
int[] cipherzigzag = new int[8];
string pesanawal,pesanenkrip;
int p,q,n,t,ee,rn,d;
Random random = new Random();
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
//


Universitas Sumatera Utara

72

// TODO: Add constructor code after the InitializeComponent() call.
//
}
public int modexp(int x, int y, int n)
{
int z = 1;
for (int i = 0; i < y ; i++){
z = (x * z) % n;
}
return z;
}
public int modInverse(int a, int n)
{
int i = n, v = 0, d = 1;
while (a>0)

{
int t = i/a, x = a;
a = i % x;
i = x;
x = d;
d = v - t*x;
v = x;
}
v %= n;
if (v