Skip to content

Instantly share code, notes, and snippets.

@csexton
Forked from cupakromer/Compiling
Created December 19, 2012 18:54
Show Gist options
  • Save csexton/4339352 to your computer and use it in GitHub Desktop.
Save csexton/4339352 to your computer and use it in GitHub Desktop.
Compile with `gcc -Wall -lssl -lcrypto shait.c`
// Compile with:
// gcc shait.c -lssl -lcrypto
#include <stdio.h>
#include <openssl/sha.h>
int main(int argc,char **argv)
{
SHA256_CTX context;
unsigned char md[SHA256_DIGEST_LENGTH];
int j;
SHA256_Init(&context);
SHA256_Update(&context, "hello world", 11);
SHA256_Final(md, &context);
printf("\n\n");
printf("Output should be: b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9\n");
printf("Output is : ");
for (j=0;j<SHA256_DIGEST_LENGTH;j++) printf("%02x", md[j]);
printf("\n\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment