Corrade::Utility::Sha1 class

SHA-1.

Implementation of the Secure Hash Algorithm 1. Example usage:

Utility::Sha1 sha1;

/* Add 7 bytes of string data */
sha1 << std::string{"corrade"};

/* Add four bytes of binary data */
const char data[4] = { '\x35', '\xf6', '\x00', '\xab' };
sha1 << Containers::arrayView(data);

/* Print the digest as a hex string */
Utility::Debug{} << sha1.digest().hexString();

/* Shorthand variant, treating the argument as a string */
Utility::Debug{} << Utility::Sha1::digest("corrade");

Base classes

template<std::size_t digestSize>
class AbstractHash<20>
Base template for hashing classes.

Public static functions

static auto digest(const std::string& data) -> Digest
Digest of given data.

Public functions

auto operator<<(Containers::ArrayView<const char> data) -> Sha1&
Add data for digesting.
auto operator<<(const std::string& data) -> Sha1&
auto operator<<(const char*) -> Sha1& deleted
auto digest() -> Digest
Digest of all added data.

Function documentation

static Digest Corrade::Utility::Sha1::digest(const std::string& data)

Digest of given data.

Convenience function for (Utility::Sha1{} << data).digest().

Sha1& Corrade::Utility::Sha1::operator<<(const std::string& data)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Sha1& Corrade::Utility::Sha1::operator<<(const char*) deleted

operator<< with C strings is not allowed

To clarify your intent with handling the '\0' delimiter, cast to Containers::ArrayView or std::string instead.