diff options
author | David Reid <dreid@dreid.org> | 2013-11-01 15:32:03 -0700 |
---|---|---|
committer | David Reid <dreid@dreid.org> | 2013-11-01 15:32:03 -0700 |
commit | 6753e39c1396dabb05e73ab7b24d9322eecbf976 (patch) | |
tree | 42179ab60188971435eb00029a4dea24dd5a27a8 /docs/hazmat | |
parent | b864db11a3577ff6b117f6ce73e43f3c1e7b3e84 (diff) | |
download | cryptography-6753e39c1396dabb05e73ab7b24d9322eecbf976.tar.gz cryptography-6753e39c1396dabb05e73ab7b24d9322eecbf976.tar.bz2 cryptography-6753e39c1396dabb05e73ab7b24d9322eecbf976.zip |
Update documentation
Diffstat (limited to 'docs/hazmat')
-rw-r--r-- | docs/hazmat/primitives/hmac.rst | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/docs/hazmat/primitives/hmac.rst b/docs/hazmat/primitives/hmac.rst index 44cc29fa..301d72d5 100644 --- a/docs/hazmat/primitives/hmac.rst +++ b/docs/hazmat/primitives/hmac.rst @@ -15,10 +15,10 @@ message authentication codes using a cryptographic hash function coupled with a secret key. You can use an HMAC to verify integrity as well as authenticate a message. -.. class:: HMAC(key, msg=None, digestmod=None) +.. class:: HMAC(key, algorithm) - HMAC objects take a ``key``, a hash class derived from - :class:`~cryptography.primitives.hashes.BaseHash`, and optional message. + HMAC objects take a ``key`` and a provider of + :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm`. The ``key`` should be randomly generated bytes and is recommended to be equal in length to the ``digest_size`` of the hash function chosen. You must keep the ``key`` secret. @@ -26,10 +26,10 @@ message. .. doctest:: >>> from cryptography.hazmat.primitives import hashes, hmac - >>> h = hmac.HMAC(key, digestmod=hashes.SHA256) + >>> h = hmac.HMAC(key, hashes.SHA256()) >>> h.update(b"message to hash") - >>> h.hexdigest() - '...' + >>> h.finalize() + '#F\xdaI\x8b"e\xc4\xf1\xbb\x9a\x8fc\xff\xf5\xdex.\xbc\xcd/+\x8a\x86\x1d\x84\'\xc3\xa6\x1d\xd8J' .. method:: update(msg) @@ -39,11 +39,10 @@ message. :return: a new instance of this object with a copied internal state. - .. method:: digest() + .. method:: finalize() - :return bytes: The message digest as bytes. - - .. method:: hexdigest() + Finalize the current context and return the message digest as bytes. - :return str: The message digest as hex. + Once ``finalize`` is called this object can no longer be used. + :return bytes: The message digest as bytes. |