ark::serialization::Hasher

Defined in header “ark/serialization/hasher.hh”.


This class wraps a hash algorithm and allows you to create a running hash from fields contained within a serialized structure.

Methods

  • void add(const Type & type)
    Adds the given object to the hash. If it’s an serializable structure, it will hash it recursively.

  • void add(const std::string & source)
    Adds the given string to the underlying hash.

  • void add(const std::vector< Type > & type)
    Adds the given vector to the underlying hash. Items are added recursively.

  • void add(const std::array< Type, ArraySize > & type)
    Adds the given array to the underlying hash. Items are added recursively.

  • void add(const std::map< Key, Value > & type)
    Adds the given map to the underlying hash. Keys/values are added recursively, in the order of [key, value, key, value].

  • void add(const std::chrono::nanoseconds & source)
    Adds the given duration to the underlying hash.

  • void add(const std::chrono::steady_clock::time_point & source)
    Adds the given time point to the underlying hash.

  • void add(const std::chrono::system_clock::time_point & source)
    Adds the given time point to the underlying hash.

  • void add(const std::optional< Type > & type)
    Adds the given optional field to the underlying hash. If set, the underlying type will be hashed. Otherwise, nothing will be hashed.

  • void add(const IndexedVariant< VariantSubtypes… > & value)
    Adds the current value of the variant to the underlying hash.

  • void add_primitive(const Type & type)
    Adds the given primitive to the underlying hash.

  • void add_data(const void * data, size_t length)
    Pass-through to the underlying algorithm add_data routine. Adds ’length’ bytes to the hash.

  • uint64_t finalize()
    Finalizes the hash, returning the final hash. Use this once you have added all the data yuou intend to.