Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/timohanke/motoko-sha2
Sha2 family in Motoko
https://github.com/timohanke/motoko-sha2
Last synced: 3 months ago
JSON representation
Sha2 family in Motoko
- Host: GitHub
- URL: https://github.com/timohanke/motoko-sha2
- Owner: timohanke
- License: apache-2.0
- Created: 2022-01-02T14:24:15.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-01-15T19:28:11.000Z (almost 3 years ago)
- Last Synced: 2024-04-19T01:33:16.087Z (7 months ago)
- Language: Motoko
- Size: 25.4 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-motoko - motoko-sha2 - All hash functions from the SHA2 family (sha224, sha256, sha512-224, sha512-256, sha384, sha512). (Libraries / Cryptography)
README
## The Sha2 package
[![ci](https://github.com/timohanke/motoko-sha2/actions/workflows/ci.yml/badge.svg)](https://github.com/timohanke/motoko-sha2/actions/workflows/ci.yml)
This package provides an implementation of the Sha2 family of hash functions implemented in Motoko. The supported algorithms are:
* sha224
* sha256
* sha512-224
* sha512-256
* sha384
* sha512### Usage
The code was derived from https://github.com/enzoh/motoko-sha/. In contrast to the functions there, this code can hash type `Blob`.
More generally, it can hash type `Iter`. Hence, for `data` of any of the types `Blob`, `[Nat8]` or `[var Nat8]` one can make the same call `SHA2.fromIter(#sha512,data.vals())`. For type `Blob` there is also the shorthand form `SHA2.fromBlob(#sha512,data)`. The allowed algorithms are `#sha224, #sha256, #sha384, #sha512, #sha512_224, #sha512_256`.