1.6 KiB
Message Digests
wolfcrypt.hashes
A message digest is the output of a cryptographic hash function containing a string of bytes created by a one-way formula using the original message as input.
Message digests are designed to protect the integrity of a piece of data or media to detect changes and alterations to any part of a message.
Hashing Classes
Interface
All Hashing Functions available in this module implements the following interface:
Hash
SHA-1
Attention
NIST has deprecated SHA-1 in favor of the SHA-2 variants. New applications are strongly suggested to use SHA-2 over SHA-1.
Sha
SHA-2 family
Sha256
Sha384
Sha512
Example
>>> from wolfcrypt.hashes import Sha256 >>> >>> s = Sha256() >>> s.update(b'wolf') >>> s.update(b'crypt') >>> s.digest() b'x96xe0.{x1cxbcxd6xf1x04xfex1fxdbFRx02zUx05xb6x86Rxb7x00x95xc61x8fx9dxcerx18D' >>> s.hexdigest() b'96e02e7b1cbcd6f104fe1fdb4652027a5505b68652b70095c6318f9dce0d1844' >>> >>> s.update(b'rocks') >>> s.hexdigest() b'e1a50df419d65715c48316bdc6a6f7f0485f4b26c1b107228faf17988b61c83f' >>> >>> Sha256(b'wolfcryptrocks').hexdigest() b'e1a50df419d65715c48316bdc6a6f7f0485f4b26c1b107228faf17988b61c83f' >>> >>> Sha256.new(b'wolfcryptrocks').hexdigest() b'e1a50df419d65715c48316bdc6a6f7f0485f4b26c1b107228faf17988b61c83f'