buffer_sha1(buffer, offset, size)

From ENIGMA
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Description

This function calculates the SHA-1 checksum of the subset of the contents of the buffer starting at offset and size bytes in size. If the offset given is beyond the end of the buffer, it returns the checksum of an empty buffer. If the bytes being considered go beyond the end of the buffer, the number of bytes read is truncated to the end of the buffer. SHA-1 is used for string encryption and other data authentication in programming, and also the popular GitHub source revision control services, it was designed by the United States National Security Agency.

Parameters

Parameter Data Type Description
buffer buffer_t The handle to the buffer whose checksum is to be calculated
offset std::size_t The offset into the buffer where the first byte to be read is located (in bytes)
size std::size_t The number of bytes to be used in the checksum calculation

Return Values

std::string: The string containing the SHA-1 checksum of the buffer

Example Call

// demonstrates obtaining an SHA-1 hash of the contents of a buffer
var hash;
hash = buffer_sha1(mybuffer, 0, buffer_get_size(buff));