On Sun, 20 Feb 2011 04:01:20 -0800, Paul Rubin <no.email@nospam.invalid> wrote: > Stuart Longland <redhat...@gentoo.org> writes: >> What format does hmac require the key to be in? > > It's an arbitrary string. > > I have a key in hexadecimal, do I give it the hex? Do I decode that > to binary and give it that? > > Probably yes. Do you have test vectors? See if they work.
Test case from http://www.faqs.org/rfcs/rfc2104.html : key = 0x0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b key_len = 16 bytes data = "Hi There" data_len = 8 bytes digest = 0x9294727a3638bb1c13f48ef8158bfc9d Using the hmac module: >>> hmac.hmac_md5( "Hi There", 16*"\x0b" ) '\x92\x94rz68\xbb\x1c\x13\xf4\x8e\xf8\x15\x8b\xfc\x9d' -- To email me, substitute nowhere->spamcop, invalid->net. -- http://mail.python.org/mailman/listinfo/python-list