//Simple example
XXH_32 hash1;
hash1.start();
hash1.put(cast(ubyte) 0);
auto result = hash1.finish();
//Simple example
XXH_64 hash1;
hash1.start();
hash1.put(cast(ubyte) 0);
auto result = hash1.finish();
//Simple example
XXH3_64 hash1;
hash1.start();
hash1.put(cast(ubyte) 0);
auto result = hash1.finish();
//Simple example
XXH3_128 hash1;
hash1.start();
hash1.put(cast(ubyte) 0);
auto result = hash1.finish();
//Simple example, hashing a string using xxh32Of helper function
auto hash = xxh32Of("abc");
//Let's get a hash string
assert(toHexString(hash) == "32D153FF");
//Simple example, hashing a string using xxh32Of helper function
auto hash = xxh64Of("abc");
//Let's get a hash string
assert(toHexString(hash) == "44BC2CF5AD770999"); // XXH64
//Simple example, hashing a string using xxh32Of helper function
auto hash = xxh3_64Of("abc");
//Let's get a hash string
assert(toHexString(hash) == "78AF5F94892F3950"); // XXH3/64
//Simple example, hashing a string using xxh32Of helper function
auto hash = xxh128Of("abc");
//Let's get a hash string
assert(toHexString(hash) == "06B05AB6733A618578AF5F94892F3950");
//Using the basic API
XXH_32 hash;
hash.start();
ubyte[1024] data;
//Initialize data here...
hash.put(data);
ubyte[4] result = hash.finish();
//Using the basic API
XXH_64 hash;
hash.start();
ubyte[1024] data;
//Initialize data here...
hash.put(data);
ubyte[8] result = hash.finish();
//Using the basic API
XXH3_64 hash;
hash.start();
ubyte[1024] data;
//Initialize data here...
hash.put(data);
ubyte[8] result = hash.finish();
//Using the basic API
XXH3_128 hash;
hash.start();
ubyte[1024] data;
//Initialize data here...
hash.put(data);
ubyte[16] result = hash.finish();
//Let's use the template features:
void doSomething(T)(ref T hash)
if (isDigest!T)
{
hash.put(cast(ubyte) 0);
}
XXH_32 xxh;
xxh.start();
doSomething(xxh);
auto hash = xxh.finish;
assert(toHexString(hash) == "CF65B03E", "Got " ~ toHexString(hash));
//Let's use the template features:
void doSomething(T)(ref T hash)
if (isDigest!T)
{
hash.put(cast(ubyte) 0);
}
XXH_64 xxh;
xxh.start();
doSomething(xxh);
auto hash = xxh.finish;
assert(toHexString(hash) == "E934A84ADB052768", "Got " ~ toHexString(hash));
//Let's use the template features:
void doSomething(T)(ref T hash)
if (isDigest!T)
{
hash.put(cast(ubyte) 0);
}
XXH3_64 xxh;
xxh.start();
doSomething(xxh);
auto hash = xxh.finish;
assert(toHexString(hash) == "C44BDFF4074EECDB", "Got " ~ toHexString(hash));
//Let's use the template features:
void doSomething(T)(ref T hash)
if (isDigest!T)
{
hash.put(cast(ubyte) 0);
}
XXH3_128 xxh;
xxh.start();
doSomething(xxh);
auto hash = xxh.finish;
assert(toHexString(hash) == "A6CD5E9392000F6AC44BDFF4074EECDB", "Got " ~ toHexString(hash));
assert(isDigest!XXH_32);
assert(isDigest!XXH_64);
assert(isDigest!XXH3_64);
assert(isDigest!XXH3_128);