Enumeration containing the canonical digest names. Those names should only be used by hashlib.new() or hmac.new(). Their support by _hashlib.new() is not necessarily guaranteed.
| 70 | |
| 71 | |
| 72 | class _HashId(enum.StrEnum): |
| 73 | """Enumeration containing the canonical digest names. |
| 74 | |
| 75 | Those names should only be used by hashlib.new() or hmac.new(). |
| 76 | Their support by _hashlib.new() is not necessarily guaranteed. |
| 77 | """ |
| 78 | |
| 79 | md5 = enum.auto() |
| 80 | sha1 = enum.auto() |
| 81 | |
| 82 | sha224 = enum.auto() |
| 83 | sha256 = enum.auto() |
| 84 | sha384 = enum.auto() |
| 85 | sha512 = enum.auto() |
| 86 | |
| 87 | sha3_224 = enum.auto() |
| 88 | sha3_256 = enum.auto() |
| 89 | sha3_384 = enum.auto() |
| 90 | sha3_512 = enum.auto() |
| 91 | |
| 92 | shake_128 = enum.auto() |
| 93 | shake_256 = enum.auto() |
| 94 | |
| 95 | blake2s = enum.auto() |
| 96 | blake2b = enum.auto() |
| 97 | |
| 98 | def __repr__(self): |
| 99 | return str(self) |
| 100 | |
| 101 | @property |
| 102 | def is_xof(self): |
| 103 | """Indicate whether the hash is an extendable-output hash function.""" |
| 104 | return self.startswith("shake_") |
| 105 | |
| 106 | @property |
| 107 | def is_keyed(self): |
| 108 | """Indicate whether the hash is a keyed hash function.""" |
| 109 | return self.startswith("blake2") |
| 110 | |
| 111 | |
| 112 | CANONICAL_DIGEST_NAMES = frozenset(map(str, _HashId.__members__)) |
no outgoing calls
no test coverage detected
searching dependent graphs…