Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This facility is "built in" to Rails, with MessageEncryptor and MessageVerifier. Before you consider writing your own "apply an HMAC-SHA1 hash to a string" library in Ruby, just take those classes from ActiveSupport instead. They've been reasonably well tested.


Alternatively, if you are not using Rails but are still using Ruby, then you can use OpenSSL::HMAC.


This is a MUCH WORSE IDEA. Don't do this. Even this Python wrapper library does a better job providing HMAC services to users than OpenSSL's HMAC primitive does. Leave OpenSSL:* to the suckers^H^H^H^H^H^H crypto library implementors.


The wrapper is pretty elegant weighing in at 3 functions; it all depends on how high-level you want to go.

If people are having trouble they can refer to the Rails ActiveSupport source code for help.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: