sha256

    MoonBit sha256: provide simple sha256 hash algorithm.

    sha256
    hash
    algorithm
    moonbit
    Download zip
    Author
    Version
    0.18.0
    License
    Apache-2.0
    Last updated
    4 days ago
    Downloads
    2K

    Dependencies

    #gmlewis/sha256

    check

    This is a simple sha256 hash algorithm based on Go's implementation: https://cs.opensource.google/go/go/+/refs/tags/go1.23.0:src/crypto/sha256/sha256.go which has the copyright notice:

    // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file.

    #Status

    The code has been updated to support compiler:

    $ moon version --all moon 0.1.20260920 (914d7da 2026-09-20) ~/.moon/bin/moon moonc v0.10.14+7d59c7ec9 (2026-09-18) ~/.moon/bin/moonc moonrun 0.1.20260920 (914d7da 2026-09-20) ~/.moon/bin/moonrun

    HashFunc

    pub(open) trait HashFunc {
    fn name(Self) -> String
    fn reset(Self) -> Unit
    fn size(Self) -> Int
    fn write(Self, Byte) -> Unit
    fn check_sum(Self) -> String
    }

    HashFunc represents a hash algorithm like @sha256, @md5, or @crc32.

    A HashFunc can be injected into other packages as a trait object (&HashFunc), which lets a caller feed data to an algorithm it does not know statically, reuse that algorithm across inputs via reset, and identify it at runtime via name.

    Implementers in other packages should declare the promotion explicitly. Promoting a trait's methods to inherent methods is deprecated (moonc warns implicit_impl_as_method), so a foreign implementation also needs a declaration such as: pub extend MyDigest with @sha256.HashFunc::{name, reset, size, write, check_sum}

    Digest

    type Digest

    Digest represents the partial evaluation of a checksum.
    impl HashFunc for Digest

    Digest::check_sum

    fn Digest::check_sum(self : Digest) -> String

    Digest::name

    fn Digest::name(self : Digest) -> String

    Digest::new

    fn Digest::new() -> Digest

    Digest::new returns a new, reset Digest, ready to sum.

    Digest::reset

    fn Digest::reset(self : Digest) -> Unit

    Digest::size

    fn Digest::size(_self : Digest) -> Int

    Digest::write

    fn Digest::write(self : Digest, b : Byte) -> Unit

    gen_hmac

    fn gen_hmac(body : Bytes, client_secret : Bytes) -> String

    gen_hmac generates a base64-encoded String representing the SHA256 signature of the provided body using the provided client_secret key.

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io