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.

5 Likes