From 30b161375b168d7e32c27651f1906232b44909f8 Mon Sep 17 00:00:00 2001 From: David Reid Date: Thu, 31 Oct 2013 13:37:24 -0700 Subject: Update documentation --- docs/hazmat/primitives/cryptographic-hashes.rst | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'docs/hazmat') diff --git a/docs/hazmat/primitives/cryptographic-hashes.rst b/docs/hazmat/primitives/cryptographic-hashes.rst index c780dcb0..9bbac247 100644 --- a/docs/hazmat/primitives/cryptographic-hashes.rst +++ b/docs/hazmat/primitives/cryptographic-hashes.rst @@ -5,7 +5,7 @@ Message Digests .. currentmodule:: cryptography.hazmat.primitives.hashes -.. class:: BaseHash(data=None) +.. class:: Hash(algorithm) Abstract base class that implements a common interface for all hash algorithms that follow here. @@ -15,11 +15,11 @@ Message Digests .. doctest:: >>> from cryptography.hazmat.primitives import hashes - >>> digest = hashes.SHA256() + >>> digest = hashes.Hash(hashes.SHA256()) >>> digest.update(b"abc") >>> digest.update(b"123") - >>> digest.hexdigest() - '6ca13d52ca70c883e0f0bb101e425a89e8624de51db2d2392593af6a84118090' + >>> digest.finalize() + 'l\xa1=R\xcap\xc8\x83\xe0\xf0\xbb\x10\x1eBZ\x89\xe8bM\xe5\x1d\xb2\xd29%\x93\xafj\x84\x11\x80\x90' .. method:: update(data) @@ -29,13 +29,10 @@ Message Digests :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() - - :return str: The message digest as hex. SHA-1 ~~~~~ -- cgit v1.2.3 From 5560298b42f071db0bf7ea46c63ff52603370b38 Mon Sep 17 00:00:00 2001 From: David Reid Date: Fri, 1 Nov 2013 13:34:05 -0700 Subject: Improve Hash documentation. --- docs/hazmat/primitives/cryptographic-hashes.rst | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'docs/hazmat') diff --git a/docs/hazmat/primitives/cryptographic-hashes.rst b/docs/hazmat/primitives/cryptographic-hashes.rst index 9bbac247..a939998d 100644 --- a/docs/hazmat/primitives/cryptographic-hashes.rst +++ b/docs/hazmat/primitives/cryptographic-hashes.rst @@ -7,10 +7,16 @@ Message Digests .. class:: Hash(algorithm) - Abstract base class that implements a common interface for all hash - algorithms that follow here. + A cryptographic hash function takes an arbitrary block of data and + calculates a fixed-size bit string (a digest), such that different data + results (with a high probability) in different digests. - If ``data`` is provided ``update(data)`` is called upon construction. + This is an implementation of + :class:`cryptography.hazmat.primitives.interfaces.HashContext` meant to + be used with + :class:`cryptography.hazmat.primitives.interfaces.HashAlgorithm` + implementations to provide an incremental interface to calculating + various message digests. .. doctest:: @@ -30,6 +36,9 @@ Message Digests :return: a new instance of this object with a copied internal state. .. method:: finalize() + Finalize the current context and return the message digest as bytes. + + Once ``finalize`` is called this object can no longer be used. :return bytes: The message digest as bytes. -- cgit v1.2.3