using methods base64 module in conjunction with Crypto.Hash.SHA256
Klaas
mike.klaas at gmail.com
Wed Dec 20 15:53:34 EST 2006
mirandacascade at yahoo.com wrote:
> I am attempting to implement a process, and I'm pretty sure that a
> major roadblock is that I do not understand the nomenclature. The
> specs indicate that the goal is to calculate a message digest using an
> SHA-256 algorithm. There are 2 examples included with the specs. The
> label on the 2 examples are: 'HMAC samples'. In both examples, the
> message on which the digest is to be calculated is (the 33 chars within
> the quotes):
>
> 'This is a test of VISION services'
>
> In the first example, the value labeled 'Shared key' is the 44
> characters within the quotes:
> '6lfg2JWdrIR4qkejML0e3YtN4XevHvqowDCDu6XQEFc='
I doubt it. That is a base64 encoded value, not the value itself.
<>
> My interpretation of the first example is this: when you use an SHA-256
> algorithm to calculate a message digest on the message 'This is a test
> of VISION services' where the key is
> '6lfg2JWdrIR4qkejML0e3YtN4XevHvqowDCDu6XQEFc=',
This isn't the key, but the base64-encoded key.
> the result should be:
> 'KF7GkfXkgXFNOgeRud58Oqx2equmKACAwzqQHZnZx9A=' .
This isn't the result, but the base64-encoded result.
> 2) If the interpretation of the first example is on target, do you see
> anything above in the use of the SHA256, HMAC and base64
> classes/methods that indicates that I did not correctly implement the
> process?
You should base64 decode the key before passing it to the HMAC
constructor.
-Mike
More information about the Python-list
mailing list