go-ruby-digest

Ruby's Digest message-digest suite in pure Go — MRI-compatible, no cgo.

pure Go · zero cgo MRI-compatible MD5 · SHA1 · SHA2 RMD160 BubbleBabble Digest::Instance hexdigest · base64digest MRI byte-exact 100% coverage 6 arches
Documentation GitHub
Documentation (MkDocs Material + mike) License: BSD-3-Clause Go 1.26.4+ Coverage 100%

go-ruby-digest is a pure-Go (no cgo) reimplementation of Ruby's Digest message-digest suite — MD5, SHA1, the SHA2 family (SHA256/384/512) and RIPEMD-160, plus BubbleBabble — whose hexdigest / digest / base64digest output matches reference Ruby byte-for-byte. It implements the Digest::Instance protocol: the streaming update / << / reset / finish interface and the one-shot Digest::MD5.hexdigest(s) class methods. It was extracted from rbgo's prelude/internals into a reusable standalone library: no dependency on the Ruby runtime, the dependency runs the other way. It is the digest backend for go-embedded-ruby, bound by rbgo as a native module just like go-ruby-regexp and go-ruby-erb — differential-tested against MRI, 100% coverage, CI green across 6 arches and 3 OSes.

Digest suite ready

MD5, SHA1, the SHA2 family (SHA256/384/512) and RIPEMD-160, each producing the same hexdigest / digest / base64digest output as reference Ruby.

Digest::Instance protocol ready

The streaming update / << / reset / finish interface and the one-shot Digest::MD5.hexdigest(s) class methods, mirroring MRI’s protocol.

BubbleBabble ready

Digest.bubblebabble / hexencode producing the human-readable BubbleBabble encoding byte-for-byte as Ruby’s digest/bubblebabble does.

Hex & base64 forms ready

hexdigest, base64digest and raw digest, with MRI’s exact byte and character output for each.

Streaming equivalence ready

Feeding input incrementally via update yields the same digest as a single one-shot call, the property reference Ruby guarantees.

Differential oracle & coverage ready

A wide input corpus hashed both here and by the system ruby/digest, compared byte-for-byte; 100% coverage, gofmt + go vet clean, green across all six 64-bit Go arches and three OSes.

A faithful port of Ruby's Digest message-digest suite in pure Go, cgo disabled, so it cross-compiles and embeds anywhere. It computes MD5, SHA1, the SHA2 family and RIPEMD-160, plus the BubbleBabble encoding, through the Digest::Instance streaming protocol and the one-shot class methods, in hexdigest / base64digest / raw digest forms. Validated differentially against the system ruby binary — digests compared byte-for-byte. It is a standalone, reusable module extracted from rbgo's internals, and the digest backend for the sibling org github.com/go-embedded-ruby.