#ifndef SHA256_C
#define SHA256_C

#include "types.c"
#include <CommonCrypto/CommonDigest.h>
#include <string.h>

byte_t *sha256(byte_t *data, size_t len) {
  byte_t *hash = malloc(CC_SHA256_DIGEST_LENGTH);
  if (hash == NULL) {
    return NULL;
  }
  CC_SHA256(data, (CC_LONG)len, hash);
  return hash;
}

#endif
