Guomi.SM3 (guomi v0.5.3)

Copy Markdown View Source

Pure Elixir SM3 cryptographic hash implementation.

SM3 is a Chinese national standard hash function (GM/T 0004-2012) producing 256-bit digests. This is a pure Elixir implementation with no external dependencies.

Summary

Functions

Hashes binary or iodata input and returns the 32-byte SM3 digest.

Hashes binary or iodata input and returns a 64-character lowercase hex digest.

Returns true; SM3 is implemented entirely in Elixir.

Types

input()

@type input() :: binary() | iodata()

Functions

hash(data)

@spec hash(input()) :: binary()

Hashes binary or iodata input and returns the 32-byte SM3 digest.

Raises ArgumentError when data is not valid iodata.

hash_hex(data)

@spec hash_hex(input()) :: String.t()

Hashes binary or iodata input and returns a 64-character lowercase hex digest.

Raises ArgumentError when data is not valid iodata.

Example

iex> Guomi.SM3.hash_hex("abc")
"66c7f0f462eeedd9d1f2d46bdc10e4e24167c4875cf2f7a2297da02b8f4ba8e0"

supported?()

@spec supported?() :: boolean()

Returns true; SM3 is implemented entirely in Elixir.