Sign in

    sha256

    A simple sha256 algorithm implemented in moonbit

    sha256
    hash
    moonbit
    Download zip
    Version
    0.1.1
    License
    Apache-2.0
    Last updated
    8 months ago
    Downloads
    317

    No dependencies

    #sha256.mbt

    MoonBit implementation of the SHA-256 hash algorithm.

    #Installation

    moon add shu-kitamura/sha256

    #Usage

    ///|
    fn main {
    let digest_bytes = @sha256.sha256(b"hello")
    // => Bytes (32 bytes)

    let digest_hex = @sha256.sha256_hexdigest(b"hello")
    // => String (64 hex chars)
    }

    #License

    Apache-2.0

    fn ch(x : UInt, y : UInt, z : UInt) -> UInt

    SHA-256 choose function.

    lower_sigma0

    fn lower_sigma0(word : UInt) -> UInt

    SHA-256 lower sigma0 function.

    lower_sigma1

    fn lower_sigma1(word : UInt) -> UInt

    SHA-256 lower sigma1 function.

    maj

    fn maj(x : UInt, y : UInt, z : UInt) -> UInt

    SHA-256 majority function.

    rtor

    fn rtor(data : UInt, shift : Int) -> UInt

    Rotate right by shift bits on a 32-bit word.

    sha256

    fn sha256(input : Bytes) -> Bytes

    Compute the SHA-256 digest as raw bytes (32 bytes).

    sha256_hexdigest

    fn sha256_hexdigest(input : Bytes) -> String

    Compute the SHA-256 digest as a hex string (64 chars).

    upper_sigma0

    fn upper_sigma0(word : UInt) -> UInt

    SHA-256 upper sigma0 function.

    upper_sigma1

    fn upper_sigma1(word : UInt) -> UInt

    SHA-256 upper sigma1 function.

    Source Files

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io