Command Palette

Search for a command to run...

sha3 package icon
chriswhealy/sha3
Public
wasmer run chriswhealy/sha3

SHA3 Implementation in WebAssembly Text

An implementation of the SHA3 algorithm in WebAssembly Text based on the specification published as NIST FIPS 202.

The resulting binary is 5.2 Kb 😎

Table of Contents

Overview

The SHA3 algorithm can be used in two modes:

  • As a drop-in replacement for SHA2, or in
  • Extendable Output Function (XOF) mode

Drop-In Replacement Mode for SHA2

When used as a drop-in replacement for SHA2, the length of the generated digest d must exacly match the digest lengths generated by SHA2. Therefore, d may only be one of 224, 256, 384, or 512 bits.

Extendible Output Function (XOF) Mode

When used in XOF mode, the SHA3 function can produce an arbitrary quantity of pseudo-random output data.

§6.2 in the above NIST FIPS 202 document describes the definition two XOF mode functions known as SHAKE128 and SHAKE256.

How Does Drop-In Mode Differ From XOF Mode?

Internally, the same hashing function is used in both modes.

The SHA3 function requires that its input data is broken up into a whole number of equally sized blocks. However, it is very unlikely that the length of the input data is an exact multiple of the block size; so, any space left at the end of the last block must be padded to ensure the last block is always full.

The first difference between the two SHA3 modes rests on how the last block is padded. The second difference rests on the amount of output data the SHA3 algorithm produces.

In Drop-in mode, the SHA3 algorithm will produce output that is exactly 224, 256, 384 or 512 bits in length. However, in XOF mode, SHA3 can generate output of arbitrary length.

Calculate the SHA3 hash of a local file as a SHA2 drop-in replacement


Github
chriswhealy/sha3 v1.3.0: Calculate the SHA3 hash of a local file as a SHA2...