I am using C language to encrypt a text file and decrypt it by the means of an AES Algorithm. This algorithm can only encrypts characters if they are stated in the format of an unsigned character where a letter A is represented by 0x41.
what i am trying to do is to read the text from the file, store it in an array of characters (of size 16 character) and then convert each character to its hexadecimal notation.
I am facing a problem in storing this notation in an unsigned characters array where i cant find the solution to store each string (0x41) in an element of the unsigned characters.
i am using the following snap of code to do the above and i hope you can grant me help to do this.
static uint8_t TextToEncrypt[16]; // For Declaring the array to store the hexadecimal notation
void ToHex(char InText[]) // The Function to Convert an array of characters to hexadecimal array
{
int i=0;
for(i=0; i<16; i++)
{
char TempBuffer[4]; // Tempbuffer to hold the converted value
sprintf(TempBuffer,"0x%x",InText[i]); // convert each character of the array of characters to the hexadecimal notation and store it in the TempBuffer
// Here i need to store the value in TempBuffer which will be something like 0x41 in TextToEncrypt[i] so i can pass it to encryption
}
}