-
-
Save csexton/4339352 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Compile with `gcc -Wall -lssl -lcrypto shait.c` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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