Implementasi Algoritma Rc4a Dan Md5 Untuk Menjamin Confidentiality Dan Integrity Pada File Teks
A-1
LAMPIRAN
LISTING PROGRAM
1. Kode Program RC4A
using
using
using
using
using
using
System;
System.IO;
System.Collections.Generic;
System.Drawing;
System.Windows.Forms;
System.Text;
namespace Sistem
{
public class RC4A
{
int[] K = new int[256];
int[] S1 = new int[256];
int[] S2 = new int[256];
public List cip = new List();
public void Kunci(string kuncii)
{
int l = kuncii.Length;
for (int i = 0; i < 256; i++) {
K[i] = (int)kuncii[i%l];
//MessageBox.Show(K[i].ToString());
}
}
public void KSA()
{
for (int i = 0; i < 256; i++) {
S1[i] = i;
}
int j = 0;
for (int i = 0; i < 256; i++) {
j = (j + S1[i] + K[i]) % 256;
int temp = S1[i];
S1[i] = S1[j];
S1[j] = temp;
}
}
public void KSA2()
{
for (int i = 0; i < 256; i++) {
S2[i] = i;
}
int j = 0;
for (int i = 0; i < 256; i++) {
Universitas Sumatera Utara
A-2B
j = (j + S2[i] + K[i]) % 256;
int temp = S2[i];
S2[i] = S2[j];
S2[j] = temp;
}
}
public string PRGA(string teks)
{
int i = 0;
int j = 0;
StringBuilder cipherst = new StringBuilder();
for (int pl = 0; pl < teks.Length; pl++) {
i = (i+1) % 256;
j = (j+S1[i]) % 256;
int temp = S1[i];
S1[i] = S1[j];
S1[j] = temp;
int z1 = S1[(S1[i] + S1[j]) % 256];
cipherst.Append(Convert.ToChar(z1));
}
return cipherst.ToString();
}
public string PRGA2(string plteks)
{
int i = 0;
int j1 = 0;
int j2 = 0;
StringBuilder cipherst = new StringBuilder();
for (int pl = 0; pl < plteks.Length; pl++) {
i = (i+1) % 256;
j1 = (j1 + S1[i]) % 256;
int temp = S1[i];
S1[i] = S1[j1];
S1[j1] = temp;
int z1 = S2[(S1[i] + S1[j1]) % 256];
int cipher1 = (int)plteks[pl] ^ z1;
j2 = (j2 + S2[i]) % 256;
int temp1 = S2[i];
S2[i] = S2[j2];
S2[j2] = temp1;
int z2 = S1[(S2[i] + S2[j2]) % 256];
int cipher2 = cipher1 ^ z2;
cip.Add(cipher2);
cipherst.Append(Convert.ToChar(cipher2));
}
return cipherst.ToString();
}
}
}
Universitas Sumatera Utara
A-3C
2. Kode Program MD5
using System;
using System.Text;
using System.Diagnostics;
namespace Sistem
{
public class MD5
{
private static int[] S
= { 7, 12, 17, 22, 5, 9, 14, 20, 4,11, 16, 23, 6, 10, 15, 21};
private static int[] Tabel_T = new int[64];
private static void tabel() {
//pembuatan tabel T[i]
unchecked{
for (int i = 0; i < 64; i++){
Tabel_T[i] = (int) (long) ((1L > 6) + 1;
int jumlah = block 8);
}
int
int
int
int
a
b
c
d
=
=
=
=
BUFF_A;
BUFF_B;
BUFF_C;
BUFF_D;
int[] buffer = new int[16];
Universitas Sumatera Utara
A-4D
for(int i = 0; i < block; i++){
int index = i > 2)] = ((int) ((index
< pesanByte) ? input [index]
: padding[index pesanByte]) > 2)]
>> 8);
int
int
int
int
for
A = a;
B = b;
C = c;
D = d;
(int j = 0; j < 64; j++){
int fungsi = (int)((uint)j >> 4);
int f = 0;
int bufferIndex = j;
switch (fungsi){
case 0 :
f = (b & c) | (~b & d);
break;
case 1 :
f = (b & d) | (c & ~d);
bufferIndex
= (bufferIndex * 5 + 1) & 0x0F;
break;
case 2 :
f = b ^ c ^ d;
bufferIndex
= (bufferIndex * 3 + 5) & 0x0F;
break;
case 3 :
f = c ^ (b | ~d);
bufferIndex
= (bufferIndex * 7) & 0x0F;
break;
}
int temp
= RotateLeft(a + f + buffer[bufferIndex]
+ Tabel_T[j], S[(fungsi
> 8);
}
}
return md5;
}
}
public String toHexString(byte[] hex){
StringBuilder sb = new StringBuilder();
for(int i = 0; i < hex.Length; i++){
sb.Append((hex[i] & 0xFF).ToString("X2"));
}
return sb.ToString();
}
static int RotateLeft(int value, int shift)
{
unchecked{
uint uvalue = (uint) value;
uint uresult = (uvalue > 32 shift);
return (int) uresult;
}
}
}
}
Universitas Sumatera Utara
B-1
CURRICULUM VITAE
1. Biodata
Nama
: Nur Hayati
Alamat Sekarang
: Jln. Dr. Mansyur Gg. Sipirok No. 16H Medan
Alamat Orang Tua
: Jln. ST. Mhd. Arief Gg.Lurah Padangsidimpuan
Telp/ Hp
: 085658090062
Email
: n3rhayati@gmail.com
2. Riwayat Pendidikan
2012 – 2016
: S1 Ilmu Komputer Universitas Sumatera Utara
2009 – 2012
: SMA Negeri 1 Padangsidimpuan
2006 – 2009
: SMP Negeri 1 Padangsidimpuan
2000 – 2006
: SD Negeri 200117 Padangsidimpuan
3. Keahlian
Bahasa
: Indonesia, Inggris
Pemrograman
: C#, Pascal, C++
Database
: MySql
Perkantoran
: Microsoft Office
4. Kursus yang Diikuti
2016
: Les Bahasa Inggris di Briton
5. Pengalaman Organisasi
[2014 – Sekarang]
: Anggota Ilmu Komputer Laboratory Center (IKLC)
Universitas Sumatera Utara
B-27
6. Pengalaman Kerja
[2014 – Sekarang]
: Asisten Ilmu Komputer Laboratory Center (IKLC)
7. Seminar
[2014]
: Seminar Nasional Literasi Informasi “SENARAI”
[2014]
: Seminar Internasional “Young People of Character-The Hope
of the Future”
Universitas Sumatera Utara
LAMPIRAN
LISTING PROGRAM
1. Kode Program RC4A
using
using
using
using
using
using
System;
System.IO;
System.Collections.Generic;
System.Drawing;
System.Windows.Forms;
System.Text;
namespace Sistem
{
public class RC4A
{
int[] K = new int[256];
int[] S1 = new int[256];
int[] S2 = new int[256];
public List cip = new List();
public void Kunci(string kuncii)
{
int l = kuncii.Length;
for (int i = 0; i < 256; i++) {
K[i] = (int)kuncii[i%l];
//MessageBox.Show(K[i].ToString());
}
}
public void KSA()
{
for (int i = 0; i < 256; i++) {
S1[i] = i;
}
int j = 0;
for (int i = 0; i < 256; i++) {
j = (j + S1[i] + K[i]) % 256;
int temp = S1[i];
S1[i] = S1[j];
S1[j] = temp;
}
}
public void KSA2()
{
for (int i = 0; i < 256; i++) {
S2[i] = i;
}
int j = 0;
for (int i = 0; i < 256; i++) {
Universitas Sumatera Utara
A-2B
j = (j + S2[i] + K[i]) % 256;
int temp = S2[i];
S2[i] = S2[j];
S2[j] = temp;
}
}
public string PRGA(string teks)
{
int i = 0;
int j = 0;
StringBuilder cipherst = new StringBuilder();
for (int pl = 0; pl < teks.Length; pl++) {
i = (i+1) % 256;
j = (j+S1[i]) % 256;
int temp = S1[i];
S1[i] = S1[j];
S1[j] = temp;
int z1 = S1[(S1[i] + S1[j]) % 256];
cipherst.Append(Convert.ToChar(z1));
}
return cipherst.ToString();
}
public string PRGA2(string plteks)
{
int i = 0;
int j1 = 0;
int j2 = 0;
StringBuilder cipherst = new StringBuilder();
for (int pl = 0; pl < plteks.Length; pl++) {
i = (i+1) % 256;
j1 = (j1 + S1[i]) % 256;
int temp = S1[i];
S1[i] = S1[j1];
S1[j1] = temp;
int z1 = S2[(S1[i] + S1[j1]) % 256];
int cipher1 = (int)plteks[pl] ^ z1;
j2 = (j2 + S2[i]) % 256;
int temp1 = S2[i];
S2[i] = S2[j2];
S2[j2] = temp1;
int z2 = S1[(S2[i] + S2[j2]) % 256];
int cipher2 = cipher1 ^ z2;
cip.Add(cipher2);
cipherst.Append(Convert.ToChar(cipher2));
}
return cipherst.ToString();
}
}
}
Universitas Sumatera Utara
A-3C
2. Kode Program MD5
using System;
using System.Text;
using System.Diagnostics;
namespace Sistem
{
public class MD5
{
private static int[] S
= { 7, 12, 17, 22, 5, 9, 14, 20, 4,11, 16, 23, 6, 10, 15, 21};
private static int[] Tabel_T = new int[64];
private static void tabel() {
//pembuatan tabel T[i]
unchecked{
for (int i = 0; i < 64; i++){
Tabel_T[i] = (int) (long) ((1L > 6) + 1;
int jumlah = block 8);
}
int
int
int
int
a
b
c
d
=
=
=
=
BUFF_A;
BUFF_B;
BUFF_C;
BUFF_D;
int[] buffer = new int[16];
Universitas Sumatera Utara
A-4D
for(int i = 0; i < block; i++){
int index = i > 2)] = ((int) ((index
< pesanByte) ? input [index]
: padding[index pesanByte]) > 2)]
>> 8);
int
int
int
int
for
A = a;
B = b;
C = c;
D = d;
(int j = 0; j < 64; j++){
int fungsi = (int)((uint)j >> 4);
int f = 0;
int bufferIndex = j;
switch (fungsi){
case 0 :
f = (b & c) | (~b & d);
break;
case 1 :
f = (b & d) | (c & ~d);
bufferIndex
= (bufferIndex * 5 + 1) & 0x0F;
break;
case 2 :
f = b ^ c ^ d;
bufferIndex
= (bufferIndex * 3 + 5) & 0x0F;
break;
case 3 :
f = c ^ (b | ~d);
bufferIndex
= (bufferIndex * 7) & 0x0F;
break;
}
int temp
= RotateLeft(a + f + buffer[bufferIndex]
+ Tabel_T[j], S[(fungsi
> 8);
}
}
return md5;
}
}
public String toHexString(byte[] hex){
StringBuilder sb = new StringBuilder();
for(int i = 0; i < hex.Length; i++){
sb.Append((hex[i] & 0xFF).ToString("X2"));
}
return sb.ToString();
}
static int RotateLeft(int value, int shift)
{
unchecked{
uint uvalue = (uint) value;
uint uresult = (uvalue > 32 shift);
return (int) uresult;
}
}
}
}
Universitas Sumatera Utara
B-1
CURRICULUM VITAE
1. Biodata
Nama
: Nur Hayati
Alamat Sekarang
: Jln. Dr. Mansyur Gg. Sipirok No. 16H Medan
Alamat Orang Tua
: Jln. ST. Mhd. Arief Gg.Lurah Padangsidimpuan
Telp/ Hp
: 085658090062
: n3rhayati@gmail.com
2. Riwayat Pendidikan
2012 – 2016
: S1 Ilmu Komputer Universitas Sumatera Utara
2009 – 2012
: SMA Negeri 1 Padangsidimpuan
2006 – 2009
: SMP Negeri 1 Padangsidimpuan
2000 – 2006
: SD Negeri 200117 Padangsidimpuan
3. Keahlian
Bahasa
: Indonesia, Inggris
Pemrograman
: C#, Pascal, C++
Database
: MySql
Perkantoran
: Microsoft Office
4. Kursus yang Diikuti
2016
: Les Bahasa Inggris di Briton
5. Pengalaman Organisasi
[2014 – Sekarang]
: Anggota Ilmu Komputer Laboratory Center (IKLC)
Universitas Sumatera Utara
B-27
6. Pengalaman Kerja
[2014 – Sekarang]
: Asisten Ilmu Komputer Laboratory Center (IKLC)
7. Seminar
[2014]
: Seminar Nasional Literasi Informasi “SENARAI”
[2014]
: Seminar Internasional “Young People of Character-The Hope
of the Future”
Universitas Sumatera Utara