sha256C代码例子
a.c
#include <stdio.h>
#include <string.h>
#include <openssl/sha.h>
1 int main(int argc, char *argv[]) 2 { 3 char data[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; 4 char hash_calc[32] = {0}; 5 SHA256_CTX c; 6 SHA256_Init(&c); 7 SHA256_Update(&c, (void *)data, 10); 8 SHA256_Final(hash_calc, &c); 9 10 11 return 0; 12 }
1 Makefile 2 3 gcc -o a.out a.c -lcrypto