"Sputnik" help  
Sputnik Help
HashUpdateFile(<hashContext>, <file>)


Updates a hash context with the contents of a file during a hashing operation. This function allows for the incremental hashing of large files without loading the entire content into memory.


<hashContext> The hash context to be updated.
<file> The path to the file whose contents will be included in the hash computation.

Return Value

Success: Returns true.
Failure: Returns false.


Use HashUpdateFile in conjunction with HashInit to incrementally hash the contents of a file. This is particularly useful for efficiently processing large files in a memory-efficient manner, updating the hash context as data is read from the file.


HashInit, HashUpdate, HashFinal, HashCopy, HashUpdateStream


Example of usage:

my $hash = HashInit("gost", @HashOptHMac, "secretKey");
HashUpdateFile($hash, "SputnikWin.dll");
HashUpdateFile($hash, "SputnikNative.dll");
say HashFinal($hash);

// 75AFFD0DC35818A89E4712127526C5B4750BC5575A67B24EE6FEB23AD070FE8A

In this example, a hash context is initialized using the GOST hash algorithm with HMAC (Hash-Based Message Authentication Code) enabled and a secret key provided using HashInit("gost", @HashOptHMac, "secretKey"). The HashUpdateFile function is then used to incrementally update the hash context with the contents of two files, "SputnikWin.dll" and "SputnikNative.dll." Finally, HashFinal is called to obtain the resulting hash value. The output, "56FAFEECA6A4A191D893A4E0C34EBA828AC30F9D46D38CDECE6A15E949478DA4," represents the HMAC-GOST hash of the concatenated contents of the specified files with the provided secret key. This demonstrates the usage of HMAC for secure hash computations with file input.

Cheryl (uberfox@hotmail.com)