Skip to content
This repository was archived by the owner on Nov 22, 2026. It is now read-only.

mojo-hashlib v0.1.0

Choose a tag to compare

@amarbarosys amarbarosys released this 21 Oct 07:18
· 21 commits to main since this release

mojo-hashlib v0.1.0

Released: 2026-10-21 · Commit: 132cc40 · Previous: first release

What it does

sha256, sha1 and md5 with incremental update() and hexdigest(), plus shlex quote, join and split, byte for byte the same as Python's hashlib and shlex.

Highlights

  • Identical to Python on 77 cases, including the padding edges at 55, 56, 63, 64 and 65 bytes and 100 KB of random data.
  • shlex is about 30x faster than Python (100k rounds: 49 to 58 ms vs 1,551 to 1,562 ms); many small hashes 2x faster.
  • One fixed 64-byte block buffer per hasher; whole blocks are hashed straight from the caller's bytes.

Changes

First public release, no earlier version.

Verified

Check Result
scripts/check.sh: 77 cases vs Python hashlib and shlex PASS all
scripts/ci.sh on a pristine Ubuntu 24.04.5 VM PASS all

Known limits

  • Bulk hashing is slower than Python, which uses OpenSSL with the CPU's SHA instructions: sha256 5.3x, sha1 2.2x, md5 1.2x slower on 64 MiB.
  • No blake2 or sha512 yet.
  • shlex is POSIX mode only.

Upgrade / run

git clone https://github.com/amarbaro/mojo-hashlib && cd mojo-hashlib && uv sync
mojo run -I src examples/quickstart.mojo

Commits

  • 132cc40 docs: CI badge
  • 5a3a05b chore: real uv.lock, oracle docstring names only what it prints
  • a9edcce docs(hashlib): README, api, design, agent skill, quickstart and CI
  • 37d7393 bench(hashlib): hashes and shlex against Python, same work and same results
  • 3f8aa77 test(hashlib): edge cases for the documented API
  • a5d5149 test(hashlib): Mojo case runner for the oracle gate
  • 7ad5123 feat(hashlib): shlex quote, join and split
  • b201412 feat(hashlib): sha256, sha1 and md5 as one generic hasher
  • 9493e97 test(hashlib): hashlib and shlex oracle, 77 cases
  • 8c5c73c chore: repo layout, Apache-2.0, mojo>=1.1