"Sputnik" help  
Sputnik Help
HashFinal(<hashContext>, [<rawOutput>])

Description

 

Parameters

<hashContext> The hash context to be finalized.
[<rawOutput>] Optional. Determines whether the output should be in raw binary format or as a hexadecimal string (default).

Return Value

Success: Returns the final hash value as either a raw binary string or a hexadecimal string, depending on the value of [<rawOutput>].
Failure: Returns an empty string or binary (depending on <rawOutput>) if the hashing process encounters an issue.

Remarks

After initializing a hash context with HashInit and updating it with data using HashUpdate, use HashFinal to complete the hash computation and retrieve the final hash value. The optional parameter [<rawOutput>] controls the format of the output.

Related

HashInit, HashUpdate, HashCopy, HashUpdateFile, HashUpdateStream

Example

Example of usage:

my $hash = HashInit("gost");
HashUpdate($hash, "Cat");
say HashFinal($hash);

my $hash = HashInit("gost");
HashUpdate($hash, "Cat");
HashUpdate($hash, "Dog");
say HashFinal($hash);

// PRINTS
// CEA32112D34163EB607E8F19CC8C8E2D2B11268088D35F71757AABA6A11D40B8
// 5D32789DD6F8F25FBDEE44F875FABC1556AE8A97F3619EE8CE04D548595D0973

In the given example, two hash computations are showcased using the GOST hash algorithm in Sputnik. In the first instance, the hash context is initialized with the string "Cat," and the resulting hash is calculated and printed. In the second case, the same hash context is updated with an additional string, "Dog," before finalizing and printing the resulting hash. The hash values demonstrate the unique fingerprints generated by the GOST algorithm for the given input data. The ability to update the hash context allows for the incremental hashing of data, and each distinct input produces a different hash output, highlighting the cryptographic strength of the GOST hash function.


Contact
Cheryl (uberfox@hotmail.com)
Homepage
http://ubersoft.org