Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added single sha256() hash function
  • Loading branch information
lcn2 committed May 30, 2017
commit 49047cb65121e7d9156434205d1a871ab0fcacd9
9 changes: 9 additions & 0 deletions sha256.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,12 @@ void sha256_final(SHA256_CTX *ctx, BYTE hash[])
hash[i + 28] = (ctx->state[7] >> (24 - i * 8)) & 0x000000ff;
}
}

void sha256(BYTE hash[], BYTE data[], size_t len)
{
SHA256_CTX ctx;

sha256_init(&ctx);
sha256_update(&ctx, data, len);
sha256_final(&ctx,hash);
}
1 change: 1 addition & 0 deletions sha256.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ typedef struct {
void sha256_init(SHA256_CTX *ctx);
void sha256_update(SHA256_CTX *ctx, const BYTE data[], size_t len);
void sha256_final(SHA256_CTX *ctx, BYTE hash[]);
void sha256(BYTE hash[], BYTE data[], size_t len);

#endif // SHA256_H