Fix for Issue #23 (#60)

* Resove computeQuickXorHash generates a different hash when files are > 64Kb
This commit is contained in:
Robert Foster 2018-07-11 06:43:45 +10:00 committed by abraunegg
parent c0d2874ace
commit f3f216c1a8

View file

@ -2,7 +2,7 @@ import std.algorithm;
import std.digest.digest;
// implementation of the QuickXorHash algorithm in D
// https://github.com/OneDrive/onedrive-api-docs/blob/master/snippets/quickxorhash.md
// https://github.com/OneDrive/onedrive-api-docs/blob/live/docs/code-snippets/quickxorhash.md
struct QuickXor
{
private immutable int widthInBits = 160;
@ -32,9 +32,9 @@ struct QuickXor
} else {
int index1 = vectorArrayIndex;
int index2 = isLastCell ? 0 : (vectorArrayIndex + 1);
byte low = cast(byte) (bitsInVectorCell - vectorOffset);
ubyte low = cast(ubyte) (bitsInVectorCell - vectorOffset);
byte xoredByte = 0;
ubyte xoredByte = 0;
for (size_t j = i; j < array.length; j += widthInBits) {
xoredByte ^= array[j];
}