Created
October 26, 2016 16:05
-
-
Save AndyNovo/b29fc6c47cc8062ed47945e7d068d649 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#include <stdio.h> | |
#include <gcrypt.h> | |
int main () { | |
size_t index; | |
size_t txtLength = 4; | |
char * hashBuffer = malloc(33); | |
char * textBuffer = malloc(txtLength+1); | |
memset(hashBuffer, 0, 33); | |
strncpy(textBuffer, "andy", txtLength); | |
gcry_md_hash_buffer( | |
GCRY_MD_SHA256, // gcry_cipher_hd_t | |
hashBuffer, // void * | |
textBuffer, // const void * | |
txtLength); // size_t | |
printf("hashBuffer = "); | |
for (index = 0; index<32; index++) | |
printf("%02X", (unsigned char)hashBuffer[index]); | |
printf("\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment