dauletle
December 3rd, 2013, 04:58 PM
Hi all! This is a quick (and hopefully simple question) regarding running a compiled c program. I wrote a program using the openssl/sha.h library that looked something like this:
int main()
{
const int DataLen = 64;
SHA_CTX shactx;
unsigned char digest[SHA_DIGEST_LENGTH];
printf("\r\nSHA-1 Message secret Hasher\r\n");
printf("\r\nComputing Secret...\r\n");
SHA1_Init(&shactx);
SHA1_Update(&shactx, Message, DataLen);
SHA1_Final(digest, &shactx);
printf("Message Hashed.\r\n");
printf("%02x ", Message[0]);
printf("%02x ", Message[1]);
printf("%02x ", Message[2]);
printf("%02x ", Message[3]);
printf("%02x ", Message[48]);
printf("%02x ", Message[49]);
printf("%02x ", Message[50]);
printf("%02x\r\n", Message[51]);
}
Once I write the code, I compile it by entering the following in the terminal:
gcc -g -Wall -Werror -std=c99 -ansi -pedantic -c main.c -o SHAHash
The code compiles with no errors. So when I try to run it with the "sudo ./SHAHash" command, I get the following error:
./SHASearch: 1: ./SHASearch: Syntax error: word unexpected (expecting ")")
I felt like this was a straightforward process, but I feel that using the special library incorrectly would cause this issue. Once again, any advice would be appreciated. Thank you
int main()
{
const int DataLen = 64;
SHA_CTX shactx;
unsigned char digest[SHA_DIGEST_LENGTH];
printf("\r\nSHA-1 Message secret Hasher\r\n");
printf("\r\nComputing Secret...\r\n");
SHA1_Init(&shactx);
SHA1_Update(&shactx, Message, DataLen);
SHA1_Final(digest, &shactx);
printf("Message Hashed.\r\n");
printf("%02x ", Message[0]);
printf("%02x ", Message[1]);
printf("%02x ", Message[2]);
printf("%02x ", Message[3]);
printf("%02x ", Message[48]);
printf("%02x ", Message[49]);
printf("%02x ", Message[50]);
printf("%02x\r\n", Message[51]);
}
Once I write the code, I compile it by entering the following in the terminal:
gcc -g -Wall -Werror -std=c99 -ansi -pedantic -c main.c -o SHAHash
The code compiles with no errors. So when I try to run it with the "sudo ./SHAHash" command, I get the following error:
./SHASearch: 1: ./SHASearch: Syntax error: word unexpected (expecting ")")
I felt like this was a straightforward process, but I feel that using the special library incorrectly would cause this issue. Once again, any advice would be appreciated. Thank you