wolfssl-examples/hash
Anthony 73dde4a277 Add BLAKE2b/BLAKE2s examples
Incremental hashing checked against the RFC 7693 known-answer vectors,
plus BLAKE2b's native keyed mode used as a MAC.
2026-07-29 13:38:44 -04:00
..
blake2 Add BLAKE2b/BLAKE2s examples 2026-07-29 13:38:44 -04:00
Ascon-Hash256.c move var declarations to the beginning of the block 2026-06-17 13:45:28 +02:00
Makefile Add CI that builds and runs every example (#598) 2026-07-23 10:07:06 -06:00
README.md Fixes for Ascon-Hash256 2026-05-01 09:07:21 +02:00
hash-file.c F-1698 F-1699 F-2094 F-2097 F-3222 F-3465 F-3900 F-4130 F-4599 F-5611 F-6285: fix logic and conditional bugs 2026-07-10 16:56:42 -06:00
input.txt Hash examples: add more 2025-03-18 12:22:24 +10:00
sha3-256-hash-oneshot-string.c Hash examples: add more 2025-03-18 12:22:24 +10:00
sha3-256-hash.c F-1298 F-1302 F-1307 F-1712 F-1713 F-1719 F-1720 F-1721 F-1722 F-2093 F-3466 F-3472 F-3477 F-4131 F-4132 F-4600 F-5612 F-6286 F-6289 F-6536: Fix error handling in crypto and signature examples 2026-07-14 15:06:41 -06:00
sha256-hash-oneshot-string.c Hash examples: add more 2025-03-18 12:22:24 +10:00
sha256-hash-string.c Hash examples: add more 2025-03-18 12:22:24 +10:00
sha256-hash.c F-1298 F-1302 F-1307 F-1712 F-1713 F-1719 F-1720 F-1721 F-1722 F-2093 F-3466 F-3472 F-3477 F-4131 F-4132 F-4600 F-5612 F-6286 F-6289 F-6536: Fix error handling in crypto and signature examples 2026-07-14 15:06:41 -06:00
sha512-hash.c F-1298 F-1302 F-1307 F-1712 F-1713 F-1719 F-1720 F-1721 F-1722 F-2093 F-3466 F-3472 F-3477 F-4131 F-4132 F-4600 F-5612 F-6286 F-6289 F-6536: Fix error handling in crypto and signature examples 2026-07-14 15:06:41 -06:00

README.md

Examples demonstrating Hash

Building

Build and install wolfSSL

./configure && make && sudo make install

Build Example

make
gcc -fsanitize=address -o sha256-hash sha256-hash.c -Wall -I/usr/local/include -Os -L/usr/local/lib -lm -lwolfssl

Debug

To enable debug change the Makefile to:

CFLAGS+=$(DEBUG_FLAGS)
#CFLAGS+=$(OPTIMIZE)

Build wolfSSL adding --enable-debug and --disable-shared to the ./configure.

Library

To enable using the static library change the Makefile to:

LIBS+=$(STATIC_LIB)
#LIBS+=$(DYN_LIB)

Usage

Ascon-Hash256

This example shows how to hash an input file using Ascon-Hash256.

./Ascon-Hash256 input.txt
Hash input file input.txt
Hash result is: cfef206d17eff5187fe5b5451326d5489eab2d65fe71faab84a6d9300ef7c6f8

sha256-hash

This example shows how to hash an input file using SHA-256.

./sha256-hash input.txt
Hash input file input.txt
Hash result is: 75294625788129796c09fcbf313ea16e2883356e322adc2f956b37dbdc10b6a7

sha512-hash

This example shows how to hash an input file using SHA-512.

./sha512-hash input.txt
Hash input file input.txt
Hash result is: ead56209da2dfb3562263aadc57d9382f0f7cb579ebb6dbf2f20bfd3cb68aaaad422f6ce6f1a88ec6c326edcf8456f650579b6e20eb39f3bb444bee8b65615ed

sha3-256-hash

This example shows how to hash an input file using SHA3-256.

./sha3-256-hash input.txt
Hash input file input.txt
Hash result is: 0704c6ca55e7e5c706b543f07da1daed8149c838549096df6a52dac5f95f2fe0

hash-file

This example shows how to hash an input file using hash wrapper API.

./hash-file SHA256 input.txt
Hash input file input.txt
Hash result is: 75294625788129796c09fcbf313ea16e2883356e322adc2f956b37dbdc10b6a7

./hash-file SHA512 input.txt
Hash input file input.txt
Hash result is: ead56209da2dfb3562263aadc57d9382f0f7cb579ebb6dbf2f20bfd3cb68aaaad422f6ce6f1a88ec6c326edcf8456f650579b6e20eb39f3bb444bee8b65615ed

./hash-file SHA3-256 input.txt
Hash input file input.txt
Hash result is: 0704c6ca55e7e5c706b543f07da1daed8149c838549096df6a52dac5f95f2fe0

sha256-hash-string

This example shows how to hash a string using SHA256.

./sha256-hash-string
String to hash: 'String to hash'
Hash result is: d4476d30fd94c746eb38d8a1b3931aa81d1e485be5a6362f47598017a91cb5d2

sha256-hash-oneshot-string

This example shows how to hash a string using wolfSSL's SHA-256 oneshot API.

./sha256-hash-oneshot-string
String to hash: 'String to hash'
Hash result is: d4476d30fd94c746eb38d8a1b3931aa81d1e485be5a6362f47598017a91cb5d2

sha3-256-hash-oneshot-string

This example shows how to hash a string using wolfSSL's SHA3-256 oneshot API.

./sha3-256-hash-oneshot-string
String to hash: 'String to hash'
Hash result is: 10d69e59ac10b1d81755733f323bdadca3e04e4b17df72f5b343d6da701a4225

Support

For questions please email us at support@wolfssl.com.