C sha256 sample code
#include <stdio.h>
#include <string.h>
#include <openssl/sha.h>
void encode(const unsigned char *input, char *output) {
unsigned char hash[SHA256_DIGEST_LENGTH];
SHA256_CTX sha256;
SHA256_Init(&sha256);
SHA256_Update(&sha256, input, strlen((char *)input));
SHA256_Final(hash, &sha256);
for(int i = 0; i < SHA256_DIGEST_LENGTH; i++) {
sprintf(output + (i * 2), "%02x", hash[i]);
}
output[64] = 0;
}
int main() {
const char *input = "1234567";
char output[65];
encode((unsigned char*)input, output);
printf("Encoded: %s\n", output);
return 0;
}