Function preImageJitter
Given two hash, where one is potentially the pre-image of the other, find by how much they actually differ.
string preImageJitter
(
in ref const(geod24 .bitblob .BitBlob!(64L)) h1,
in ref const(geod24 .bitblob .BitBlob!(64L)) h2,
ulong max_jitter = 1000LU
) nothrow @safe;
This utility was conceived to find off-by-one errors and the likes in code, and should only be used for debuggging, not for testing nor production.
Parameters
Name | Description |
---|---|
h1 | A hash that is likely to be the pre-image of h2 |
h2 | A hash that is likely an image of h1 |
Example
Hash h1 = "Hello World" .hashFull();
Hash h2 = h1 .hashFull .hashFull();
assert(preImageJitter(h1, h2) ==
format("h1 (%s) was a pre-image of h2 (%s) after 2 computation", h1, h2));
assert(preImageJitter(h2, h1) ==
format("h2 (%s) was a pre-image of h1 (%s) after 2 computation", h1, h2));