SHA256 for type Blob

In case anyone has needed a SHA256 implementation in Motoko for type Blob (not type [Nat8]). I made one here:

You can use it for data of any of the types Blob, [Nat8] or [var Nat8] in the exact same way, simply by writing sha256(data.vals()). That is because under the hood it accepts an iterator.

7 Likes

For the record: This has been superseded by Internet Computer Content Validation Bootstrap which is vastly more performant.

2 Likes