I wanted a pure ruby HMAC SHA1 implementation (or more specifically, one that didn't just call out to the OpenSSL libraries) because we have a tool I want to make available on Windows.
Searching about a bit turned zilch up, and just annoyed me. I lost track of the number of "pure ruby" implementations of things that I found that ultimately had a native code dependency.
So I went looking for an implementation in another language that looked reasonably easy to port.
The end result is not pretty, definitely not efficient, certainly not idiomatic, elegant or even "decent" ruby code. But it serves my purposes (signing AWS requests). In the end I ported a JavaScript library that I've used with some success before. Bit manipulation in JavaScript and Ruby differs more than I'd expected.
The working code is here. Use it, laugh at it, I don't really care.
Posted at 05:02 PM