Skip to content

Almost done. #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions AES.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,21 +406,38 @@ void AESDecryption(unsigned char * cipher, unsigned char * expandedKey, unsigned
free(state);
}

int main(int argc, char const *argv[])
nt main(int argc, char const *argv[])
{
unsigned char plainText[] = "This is a text a";
char ch;
int i;
unsigned char plainText[16];
unsigned char key[] = "This is a test a";
unsigned char * expandedKey = keyExpansion(key);
unsigned char * cipher = malloc(16);
FILE *fp;
FILE *fp1;
fp1=fopen("cipher.txt", "r+");
fp = fopen("plain.txt", "r+");
fputs("This is the text we are using for our algorithm as a plain text this will be encrypted to a cipher text soon enough", fp);
do
{
for(i=0;i<16;i++)
{
ch = fgetc(fp1); // copying file character by character
plainText[i]=ch;
}
AESEncryption(plainText, expandedKey, cipher);
for (int i = 0; i < 16; ++i)
fputs(cipher,fp1);
}
while(ch!=EOF);
for (i = 0; i < 16; ++i)
{
printf("%02X ", cipher[i] );
}printf("\n");

unsigned char * outPut = malloc(16);
AESDecryption(cipher, expandedKey, outPut);
for (int i = 0; i < 16; ++i)
for (i = 0; i < 16; ++i)
{
printf("%c", outPut[i] );
}printf("\n");
Expand Down