Well Sorry for late reply , some net problems at home, and still are ..
Here's what i am trying to do ..
AES encryption and decrytpion:
1. 128 key
2. ECB mode.
And thats what i have done so far:
1. Encrytpion in VC 6
2. Decrytpion in java
3. keys and cipher text is being send through TCP sockets
But above mentioned things are irrelevant to what i am stuck at:
BACKGROUND:
i am taking user's input of Plane text and Key in
unsigned char Key[32]; //={0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f};
unsigned char PT[32]; //={0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f};
for(i=0;i<16;i++)
{
scanf("%x",&PT[i]); //Plane text in HEXADECIMAL
}
for(i=0;i<Nb*4;i++)
{
scanf("%x",&Key[i]); //Key in HEXADECIMAL
}
and user input some thing like :
00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
and got Cypher Text like
0a940bb5416ef045f1c39458c653ea5a
NOW:
I want the user to Enter Key and Plane text like a simple string for example;
char key[]="this is my key";
char PT[]="i want to encrypt this";
""And i do the conversion from string -> hex -> unsigned char array myself in program""
----
Now i have done string ->hex part
//String to hex
f1 = fopen ("CT.txt", "wt");
char string1[64]="A simple string A simple string A simple string A simple string";
char number;
int k=0;
printf("\n");
for(;k<63;k++)
{
sscanf(&string1[k], "%c", &number);
fprintf (f1, "%x", number);
}
fclose (f1);
f1 = fopen ("CT.txt", "r");
while(!feof(f1))
if(fgets(string1, 200, f1)){}
fclose(f1);
printf("hex it is %s", string1);
And the output is
412073696d706c6520737472696e6720412073696d706c6520737472696e6720412073696d706c6520737472696e6720412073696d706c6520737472696e67
.....
Now unable to convert that hex->unsigned char array simply because
string[64] wont be assigned to PT[32]
....
I tried Dream2Code's code n the output is
A simple string A simple string ... //string1[64]
-- I NEED TO CONVERT THAT HEX[64] REPRESENTATION OF STRING TO UNSIGNED CHAR ARRAY[32] --
Tried but failed .. so tell me what to do now ... Or is there something that i am doing wrong ...
Many thanks for your replies though ...