buffer_sha1

This function takes input data from a buffer and returns a 160 bit message digest in ASCII format. In this way you can generate a secure key which can be stored and used to check the integrity of the information being sent to (or received from) an external server (for example).

In cryptography, SHA-1 is a cryptographic hashing function designed by the United States National Security Agency and is employed in several widely used applications and protocols like the popular Git where it is used to check for file changes.

When applying this to buffers using this function you must specify the buffer to use, then an offset value (in bytes) for where to begin, and then a size (again in bytes) for the region to be hashed.

NOTE SHA-1 is not completely secure and can be broken. See this page for more info.

 

Syntax:

buffer_sha1(buffer, offset, size);

ArgumentTypeDescription
bufferBufferThe buffer to use.
offsetRealThe data offset value.
sizeRealThe size of the buffer.

 

Returns:

String

 

Example:

check_string = buffer_sha1(buff, 0, buffer_get_size(buff));

The above code creates an SHA-1 hash for the full data stored in the buffer stored in the variable buff, and stores the returned hash in the variable check_string.