Last Modified
2011-09-12 22:03:57 -0700
Requires
  • digest

Description

digest/hmac.rb

An implementation of HMAC keyed-hashing algorithm

Overview

CAUTION: Use of this library is discouraged, because this implementation was meant to be experimental but somehow got into the 1.9 series without being noticed. Please use OpenSSL::HMAC in the “openssl” library instead.

This library adds a method named hmac() to Digest classes, which creates a Digest class for calculating HMAC digests.

Examples

require 'digest/hmac'

# one-liner example
puts Digest::HMAC.hexdigest("data", "hash key", Digest::SHA1)

# rather longer one
hmac = Digest::HMAC.new("foo", Digest::RMD160)

buf = ""
while stream.read(16384, buf)
  hmac.update(buf)
end

puts hmac.bubblebabble

License

Copyright © 2006 Akinori MUSHA <knu@iDaemons.org>

Documentation by Akinori MUSHA

All rights reserved. You can redistribute and/or modify it under the same terms as Ruby.

$Id: hmac.rb 28151 2010-06-03 15:04:36Z knu $
blog comments powered by Disqus