Sisyboy’s Weblog

Just another WordPress.com weblog

TUGAS STRUKTUR DATA “RC4”

#include<stdio.h>
#include<conio.h>
#include<ctype.h>
#include<string.h>
#include<alloc.h>
#include<dos.h>

#define ENTER ‘\r’

int xbox_pertama[256];
int xbox_kedua[256];
int initialkey[11];
unsigned char plaintext[7], ciphertext[7], kosong, key;
int a,b,c,d,i;

void sbox_pertama(void)
{
for(i=0;i<=255;i++)
xbox_pertama[i]=i;
}

void sbox_kedua(void)
{

printf(” Masukkan initial Key Anda : “);
gets(initialkey);

b=strlen(initialkey);
for(i=0;i<=255;i++)
{
xbox_kedua[i]=initialkey[i%b];
}
}

void kunci(void)
{
char OLD[7];
FILE *pf1;

printf(“\n\n Nama File untuk menyimpan xbox_pertama : “);
gets(OLD);

pf1=fopen(OLD,”a+”);

b=0;
for(a=0;a<=255;a++)
{
b=(b+xbox_pertama[a]+xbox_kedua[a])%256;
kosong=xbox_pertama[a];
xbox_pertama[a]=xbox_pertama[b];
xbox_pertama[b]=kosong;
}

for(a=0;a<=255;a++)
{
putc(xbox_pertama[a],pf1);
putc(‘ ‘,pf1);
}

for(a=0;a<256;a++)
{
printf(“%4d”,xbox_pertama[a]);
if((a+1)%16==0) {printf(“\n”);}
}

fclose(pf1);

}

void process(void)
{
a=0;
b=0;

printf(“\n\n Masukkan plaintext : “);
gets(“plaintext”);

for(c=0;c<6;c++)
{
a=(a+1)%256;
b=(b+xbox_pertama[a])%256;
kosong=xbox_pertama[a];
xbox_pertama[a]=xbox_pertama[b];
xbox_pertama[b]=kosong;
d=(xbox_pertama[a]+xbox_pertama[b])%256;
key=xbox_pertama[d];
ciphertext[c]=plaintext[c]^key;
printf(“\n %c -> %c”,plaintext[c],ciphertext[c]);
}

printf(“\n\n ciphertext : “);
for(a=0;a<6;a++)
{
printf(“%c “,ciphertext [a]);
}

}

main()
{
int x,y,i,j,k,pilops;
char c,kar,password[10],p[9]=”linklist”;

clrscr();

puts(“”);
puts(” *************************************”);
puts(” * *”);
puts(” * PROGRAM OPERASI PADA LINK LIST *”);
puts(” * TUGAS MATA KULIAH STRUKTUR DATA *”);
puts(” * OLEH : NEO *”);
puts(” * *”);
puts(” *************************************”);
printf(“\n\n”);

c=’\xFE’;
awal:
printf(” LOGIN :\n\n”);
printf(” MASUKKAN PASSWORD : “);
for(i=0;i<10;i++)
{
password[i]=getch();
putchar(‘*’);
if(password[i]==ENTER)
{password[i]=”; break;}
}

if(strcmp(p,password)==0) {printf(“\n\n\n LOADING\n\n “);
printf(” “);
for(i=0;i<3;i++)
{
sleep(1);
printf(“%c”,c);
}
clrscr();
printf(“\n\n”);
goto proses;
}

else {printf(“\n\n Password Anda Salah!!!\n”);
printf(“\n Ulangi LOGIN ? ( Y / T) “); kar=getche();
if(kar==’Y’||kar==’y’) {printf(“\n\n\n”); goto awal;}
if(kar==’T’||kar==’t’) goto selesai;
}

proses:
sbox_pertama();
sbox_kedua();
kunci();
process();

printf(“\n Ulangi Operasi LINK LIST ? ( Y / T) “); kar=getche();

if(kar==’Y’||kar==’y’) {printf(“\n\n\n”); goto proses;}
else goto selesai;

selesai:
getch();
}

Advertisements

May 5, 2008 - Posted by | Pemrograman Neo

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: