Asset OTA


Since 5.5.0:


Class to hold a hash (digest) of data. Currently only uses SHA-256, but could be extended to use other hash types in the future.

This class does not calculate the hash, it merely is a container that holds the hash value and type of hash, and implements useful comparison methods.

When using ApplicationAsset you can get the SHA-256 hash for an asset using the hash() method.

Constructor - AssetHash

AssetHash::constructor, constructor, AssetHash.constructor

AssetHash(const char* hash, size_t length, Type type = Type::DEFAULT);
AssetHash(const uint8_t* hash, size_t length, Type type = Type::DEFAULT);
AssetHash(const Buffer& hash, Type type = Type::DEFAULT);
AssetHash(const AssetHash& other) = default;
AssetHash(AssetHash&& other) = default;

You will typically not construct one of these as the class is instantiated by ApplicationAsset. However you can construct your own if desired. Note that the this class does not actually do the hashing; it's a container to hold the pre-hashed value.

type() - AssetHash

AssetHash::type, type, AssetHash.type

Type type() const;

Returns the type:

  • AssetHash::Type::INVALID (-1) - Invalid, occurs when using the default constructor
  • AssetHash::Type::SHA256 (0) - SHA-256 (32 byte hash)
  • AssetHash::Type::DEFAULT - Alias for AssetHash::Type::SHA256

AssetHash::Type::SHA256 AssetHash::Type::DEFAULT

hash() - AssetHash

AssetHash::hash, hash, AssetHash.hash

const Buffer& hash() const;

Returns a reference to the binary representation of the hash.

In most cases, you will use toString() or the equality test instead of this method.

isValid() - AssetHash

AssetHash::isValid, isValid, AssetHash.isValid

bool isValid() const;

Returns true if the hash type is set and is not empty.

toString() - AssetHash

AssetHash::toString, toString, AssetHash.toString

String toString() const;

Returns a text representation of the hash. For SHA-256, this is 64 lowercase hexadecimal (0-9, a-f) characters.

operator==() - AssetHash

AssetHash::operator==, operator==, AssetHash.operator==

bool operator==(const AssetHash& other) const;

Returns true if two hashes are equal.

operator!=() - AssetHash

AssetHash::operator!=, operator!=, AssetHash.operator!=

bool operator!=(const AssetHash& other) const;

Returns true if two hashes are not equal.