Edit on GitHub
Represents a 32-bit hash value resulting from a hashing operation. Hashes are computed using the CRC-32 algorithm, making it unsuitable for cryptographic purposes, but it works well for quickly comparing data and files. Hashes can be computed through the Constructor or Append functions, and retrieved at any time with Result.
Constructs a hash with Result set to zero.
Constructs a hash with a call to Append.
||(const char* file)
Opens file and appends its data to this hash without resetting it, allowing continuous hashing at any time. The data is read in 4KB chunks before being passed over to the Append function. If file could not be read, this function returns false.
Appends dataLength bytes from data to this hash without resetting it, allowing continuous hashing at any time. Ensure data contains at least dataLength bytes to avoid a buffer overflow.
Performs equality comparison on the Result.
Provides direct access to the result of this hash.
int main (void)
Hash h1 ((uint8*) "Hello ", 6);
Hash h2 ((uint8*) "World!", 6);
h1.Result; // 0xEA2DFCC0
h2.Result; // 0x76289DDE
h2.Result = 0;
h1.Append ((uint8*) "World!", 6 );
h2.Append ((uint8*) "Hello World!", 12);
h1.Result; // 0x1C291CA3
h2.Result; // 0x1C291CA3
h1 == h2; // True
h1 != h2; // False
// CRC32 Hash of MyFile
var robot = require ("robot-js");
var h1 = robot.Hash ("Hello ");
var h2 = robot.Hash ("World!");
h2.result = 0;
h1.append ( "World!");
h2.append ("Hello World!");