Mojo trait
Hasher
A trait for types that can incrementally compute hash values.
The Hasher trait defines the interface for hash algorithms that can process
data in chunks and produce a final hash value.
Implementers must provide methods to initialize the hasher, update it with data, and finalize the hash computation.
Implemented traits
AnyType,
UnknownDestructibility
Aliases
__del__is_trivial
alias __del__is_trivial
A flag (often compiler generated) to indicate whether the implementation of __del__ is trivial.
The implementation of __del__ is considered to be trivial if:
- The struct has a compiler-generated trivial destructor and all its fields
have a trivial
__del__method.
In practice, it means that the __del__ can be considered as no-op.
Required methods
__init__
__init__(out self: _Self)
Initialize a new hasher instance.
Returns:
_Self
update
update[T: Hashable](mut self: _Self, value: T)
Update the hash with a value.
Parameters:
- T (
Hashable): The type of value to hash, which must implementHashable.
Args:
- value (
T): The value to incorporate into the hash.
finish
finish(var self: _Self) -> UInt64
Finalize the hash computation and return the hash value.
Returns:
UInt64: The computed hash value as a 64-bit unsigned integer.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!