diff --git a/showcase/sha256.md b/showcase/sha256.md new file mode 100644 index 0000000..7de3454 --- /dev/null +++ b/showcase/sha256.md @@ -0,0 +1,21 @@ +--- +name: SHA256 Digest Implemented in WebAssembly Text +source_url: https://github.com/ChrisWhealy/wasm_sha256 +website: https://github.com/ChrisWhealy/wasm_sha256 +description: An implementation of the SHA256 message digest algorithm written in WebAssembly Text +keywords: sha256 webassembly webassemblytext +--- + +## SHA256 Message Digest + +Based on the excellent overview of the SHA256 algorithm available at [SHA256Algorithm](https://sha256algorithm.com/), I decided to see how small a binary I could create by implementing this functionality directly in WebAssemb;y Text. + +The results are pretty encouraging - 951 byte! + +### Known Performance Issue - But Not With WebAssembly + +The performance of the JavaScript coding used to create the host environment is known to be slow. When calculating the digest of a large file (E.G. a 100Mb MP4 movie file), the JavaScript coding is **_really_** slow... + +When testing against a big MP4 file, the program takes just over 9 seconds to complete; however, JavaScript needs 7.5 of those seconds to load the file into WASM shared memory... + +Once loaded however, the `.wasm` binary calculates the SH256 digest in a time that's very similar to the built-in macos program `sha256sum`.