Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

It is generally not recommended to use std::string as a wrapper for hashing raw buffer because std::string adds a null termination character at the end of the buffer. This null character can affect the hash value produced by the hashing function.

Additionally, std::string may allocate and deallocate memory dynamically, which can affect the performance of the hashing function. It is more efficient to use a fixed-size buffer for hashing and avoid any unnecessary memory allocations.

Instead, it is recommended to use a dedicated hashing function or library that is designed to handle raw buffers directly. Examples of such libraries include OpenSSL's SHA256, BLAKE2, or SHA3. These libraries can efficiently hash raw buffers without introducing any unnecessary overhead.