Skip to content

kazuho/picohash

master
Switch branches/tags
Code

Latest commit

…2.0-19ubuntu1) 11.2.0; using indirect call to prevent GCC detecting that `_picohash_md5_final` is triggering UB and therefore that `digest` can be any value
3a9eff9

Git stats

Files

Permalink
Failed to load latest commit information.

picohash

picohash is a header-file-only implementation of MD5, SHA1, SHA224, SHA256, HMAC.

The code is placed under public domain. It comes without any warranty, to the extent permitted by applicable law.

Calculating Hash

picohash_ctx_t ctx;
char digest[PICOHASH_MD5_DIGEST_LENGTH];

picohash_init_md5(&ctx);
picohash_update(&ctx, "hello", 5);
picohash_final(&ctx, digest);

Replace md5 with sha1, sha224, sha256 for your need.

Calculating HMAC

picohash_ctx_t ctx;
char digest[PICOHASH_SHA1_DIGEST_LENGTH];

picohash_init_hmac(&ctx, picohash_init_sha1, "my secret", strlen("my secret"));
picohash_update(&ctx, "hello", 5);
picohash_final(&ctx, digest);

Replace md5 with sha1, sha224, sha256 for your need.

About

header-file-only implementation of various hash algorithms

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages