File include/brisk/core/Cryptography.hpp
¶
ECrypto
class¶
ECrypto
Exception class for cryptographic errors.
cryptoRandomInplaceSafe
function¶
size_t cryptoRandomInplaceSafe(bytes_mutable_view data)
Retrieves cryptographically secure random bytes.
Param data
The buffer to store the random bytes.
Returns The number of bytes received.
cryptoRandomInplace
function¶
void cryptoRandomInplace(bytes_mutable_view data)
Retrieves cryptographically secure random bytes.
Param data
The buffer to store the random bytes.
Exceptions Thrown if there are not enough random bytes.
cryptoRandom
function¶
bytes cryptoRandom(size_t size)
Retrieves cryptographically secure random bytes.
Param size
The number of bytes to return.
Returns The random bytes as a bytes
object.
cryptoRandomFixed
function¶
template <size_t Size>
[[nodiscard]] inline FixedBytes<Size> cryptoRandomFixed(size_constant<Size> =
Retrieves cryptographically secure random bytes as a fixed-size array.
Template param Size
The size of the fixed byte array.
Param size_constant
The size of the fixed byte array (unused).
Returns The random bytes as a FixedBytes<Size\>
object.
cryptoRandomReader
function¶
RC<Stream> cryptoRandomReader()
Creates a RC<Stream> for cryptographically secure random bytes.
Returns A RC<Stream> for random bytes.
HashMethod
enum¶
enum class HashMethod
Enum class representing various hash methods.
MD5
enumerator (HashMethod::MD5
)¶
MD5 hashing method
SHA1
enumerator (HashMethod::SHA1
)¶
SHA-1 hashing method
SHA256
enumerator (HashMethod::SHA256
)¶
SHA-256 hashing method
SHA512
enumerator (HashMethod::SHA512
)¶
SHA-512 hashing method
SHA3_256
enumerator (HashMethod::SHA3_256
)¶
SHA3-256 hashing method
SHA3_512
enumerator (HashMethod::SHA3_512
)¶
SHA3-512 hashing method
Last
enumerator (HashMethod::Last
)¶
Sentinel value for the last hash method
hashBitSize
function¶
constexpr size_t hashBitSize(HashMethod method)
Returns the output bit size of the specified hash method.
Param method
The hash method for which to retrieve the bit size.
Returns The bit size of the hash output for the given method.
Returns 0 if the method is unrecognized.
defaultNames
variable¶
template <>
inline constexpr std::initializer_list<
NameValuePair<HashMethod>>
defaultNames<HashMethod>
Provides names for hash methods.
hash
function¶
Bytes hash(HashMethod method, bytes_view data)
Hashes a sequence of bytes using the specified hashing method.
Param method
The hashing method to use.
Param data
The sequence of bytes to hash.
Returns The resulting hash as a Bytes
object.
md5
function¶
MD5Hash md5(bytes_view data)
Computes the MD5 hash of a sequence of bytes.
Param data
The sequence of bytes to hash.
Returns The resulting MD5 hash as an MD5Hash
object.
sha1
function¶
SHA1Hash sha1(bytes_view data)
Computes the SHA-1 hash of a sequence of bytes.
Param data
The sequence of bytes to hash.
Returns The resulting SHA-1 hash as a SHA1Hash
object.
sha256
function¶
SHA256Hash sha256(bytes_view data)
Computes the SHA-256 hash of a sequence of bytes.
Param data
The sequence of bytes to hash.
Returns The resulting SHA-256 hash as a SHA256Hash
object.
sha512
function¶
SHA512Hash sha512(bytes_view data)
Computes the SHA-512 hash of a sequence of bytes.
Param data
The sequence of bytes to hash.
Returns The resulting SHA-512 hash as a SHA512Hash
object.
sha3_256
function¶
SHA3_256Hash sha3_256(bytes_view data)
Computes the SHA3-256 hash of a sequence of bytes.
Param data
The sequence of bytes to hash.
Returns The resulting SHA3-256 hash as a SHA3_256Hash
object.
sha3_512
function¶
SHA3_512Hash sha3_512(bytes_view data)
Computes the SHA3-512 hash of a sequence of bytes.
Param data
The sequence of bytes to hash.
Returns The resulting SHA3-512 hash as a SHA3_512Hash
object.
hash
function¶
Bytes hash(HashMethod method, string_view data)
Hashes a string using the specified hashing method.
Param method
The hashing method to use.
Param data
The string to hash.
Returns The resulting hash as a Bytes
object.
md5
function¶
MD5Hash md5(string_view data)
Computes the MD5 hash of a string.
Param data
The string to hash.
Returns The resulting MD5 hash as an MD5Hash
object.
sha1
function¶
SHA1Hash sha1(string_view data)
Computes the SHA-1 hash of a string.
Param data
The string to hash.
Returns The resulting SHA-1 hash as a SHA1Hash
object.
sha256
function¶
SHA256Hash sha256(string_view data)
Computes the SHA-256 hash of a string.
Param data
The string to hash.
Returns The resulting SHA-256 hash as a SHA256Hash
object.
sha512
function¶
SHA512Hash sha512(string_view data)
Computes the SHA-512 hash of a string.
Param data
The string to hash.
Returns The resulting SHA-512 hash as a SHA512Hash
object.
sha3_256
function¶
SHA3_256Hash sha3_256(string_view data)
Computes the SHA3-256 hash of a string.
Param data
The string to hash.
Returns The resulting SHA3-256 hash as a SHA3_256Hash
object.
sha3_512
function¶
SHA3_512Hash sha3_512(string_view data)
Computes the SHA3-512 hash of a string.
Param data
The string to hash.
Returns The resulting SHA3-512 hash as a SHA3_512Hash
object.
Hasher
class¶
Hasher
Provides a common interface for hashers, enabling generic hashing functionality.
Hasher
function (Hasher::Hasher
)¶
Hasher() noexcept
Default constructor. Initializes the hasher with the default hashing method.
explicit Hasher(HashMethod method) noexcept
Constructs a hasher with the specified hashing method.
Param method
The hashing method to use.
finish
function (Hasher::finish
)¶
bool finish(bytes_mutable_view hashOutput)
Finalizes the hashing process and writes the result to the provided buffer.
Param hashOutput
The buffer where the final hash result will be written.
Returns True if the finalization was successful, otherwise false.
write
function (Hasher::write
)¶
bool write(bytes_view data)
Writes a sequence of bytes to the hasher for hashing.
Param data
The sequence of bytes to hash.
Returns True if the write operation was successful, otherwise false.
bool write(const uint8_t *data, size_t size)
Writes a sequence of bytes to the hasher for hashing.
Param data
Pointer to the byte data.
Param size
The number of bytes to write.
Returns True if the write operation was successful, otherwise false.
method
variable (Hasher::method
)¶
HashMethod method
The hashing method used by this hasher.
state
variable (Hasher::state
)¶
FixedBytes<416> state
Internal state of the hasher.
SHA256Hasher
class¶
SHA256Hasher
Provides a SHA-256 specific hasher with SHA-256 as the hashing method.
SHA256Hasher
function (SHA256Hasher::SHA256Hasher
)¶
SHA256Hasher() noexcept : Hasher(HashMethod::SHA256)
Constructs a SHA256Hasher with SHA-256 as the hashing method.
finish
function (SHA256Hasher::finish
)¶
bool finish(SHA256Hash &hash)
Finalizes the hashing process and writes the result to the provided SHA256Hash object.
Param hash
The SHA256Hash object where the final hash result will be written.
Returns True if the finalization was successful, otherwise false.
SHA512Hasher
class¶
SHA512Hasher
Provides a SHA-512 specific hasher with SHA-512 as the hashing method.
SHA512Hasher
function (SHA512Hasher::SHA512Hasher
)¶
SHA512Hasher() noexcept : Hasher(HashMethod::SHA512)
Constructs a SHA512Hasher with SHA-512 as the hashing method.
finish
function (SHA512Hasher::finish
)¶
bool finish(SHA512Hash &hashOutput)
Finalizes the hashing process and writes the result to the provided SHA512Hash object.
Param hashOutput
The SHA512Hash object where the final hash result will be written.
Returns True if the finalization was successful, otherwise false.
hashStream
function¶
RC<Stream> hashStream(HashMethod method,
bytes_mutable_view hashOutput)
Creates a RC<Stream> for hashing using the specified hash method.
Param method
The hashing method to use.
Param hashOutput
The buffer where the final hash result will be written.
Returns A RC<Stream> for hashing.
md5HashStream
function¶
RC<Stream> md5HashStream(MD5Hash &hashOutput)
Creates a RC<Stream> for MD5 hashing.
Param hashOutput
The MD5Hash object where the final hash result will be written.
Returns A RC<Stream> for MD5 hashing.
sha1HashStream
function¶
RC<Stream> sha1HashStream(SHA1Hash &hashOutput)
Creates a RC<Stream> for SHA-1 hashing.
Param hashOutput
The SHA1Hash object where the final hash result will be written.
Returns A RC<Stream> for SHA-1 hashing.
sha256HashStream
function¶
RC<Stream> sha256HashStream(SHA256Hash &hashOutput)
Creates a RC<Stream> for SHA-256 hashing.
Param hashOutput
The SHA256Hash object where the final hash result will be written.
Returns A RC<Stream> for SHA-256 hashing.
sha512HashStream
function¶
RC<Stream> sha512HashStream(SHA512Hash &hashOutput)
Creates a RC<Stream> for SHA-512 hashing.
Param hashOutput
The SHA512Hash object where the final hash result will be written.
Returns A RC<Stream> for SHA-512 hashing.
sha3_256HashStream
function¶
RC<Stream> sha3_256HashStream(SHA3_256Hash &hashOutput)
Creates a RC<Stream> for SHA3-256 hashing.
Param hashOutput
The SHA3_256Hash object where the final hash result will be written.
Returns A RC<Stream> for SHA3-256 hashing.
sha3_512HashStream
function¶
RC<Stream> sha3_512HashStream(SHA3_512Hash &hashOutput)
Creates a RC<Stream> for SHA3-512 hashing.
Param hashOutput
The SHA3_512Hash object where the final hash result will be written.
Returns A RC<Stream> for SHA3-512 hashing.
Auto-generated from sources, Revision , https://github.com/brisklib/brisk/blob//include/brisk/