/* Collection of code snippets by Arne Vajhøj */
/* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) */
#include <stdio.h>
#include <string.h>

#include <openssl/sha.h>

void test(char *buf, int buflen)
{
    SHA256_CTX ctx;
    int i;
    unsigned char md[32];
    SHA256_Init(&ctx);
    SHA256_Update(&ctx, buf, buflen);
    SHA256_Final(md, &ctx);
    for(i = 0; i < 32; i++)
    {
        printf("%02x", md[i]);
    }
    printf("\n");
}

int main()
{
    char *buf = "Dette er en test!";
    test(buf, strlen(buf));
    return 0;
}

