s365b.modules.onedrive.quickxor

Microsoft’s QuickXorHash, the content hash OneDrive for Business reports.

Byte k of the content is XORed into a 160-bit value at bit (k * 11) % 160, wrapping around; the length is then XORed into the last 8 bytes. Because the bit position repeats every 160 bytes, the content is first folded into one 160-byte block (bytes 160 apart XORed together), which big-integer XOR does at bulk speed; only that block is placed bit by bit.

Attributes

Classes

QuickXorHash

Incremental QuickXorHash: update() with each piece, then digest().

Functions

quick_xor_hash(data) → str

Hash content in one go.

Module Contents

s365b.modules.onedrive.quickxor.WIDTH = 160[source]
s365b.modules.onedrive.quickxor.BLOCK = 160[source]
s365b.modules.onedrive.quickxor.SHIFT = 11[source]
class s365b.modules.onedrive.quickxor.QuickXorHash[source]

Incremental QuickXorHash: update() with each piece, then digest().

length = 0[source]
update(data: bytes) → None[source]

Add the next piece of content.

Parameters:

data – Bytes following those already added.

digest() → bytes[source]

The 20-byte hash of everything added so far.

Returns:

The hash.

b64digest() → str[source]

The hash in base64, as Graph gives it (file.hashes.quickXorHash).

Returns:

The hash.

s365b.modules.onedrive.quickxor.quick_xor_hash(data: bytes) → str[source]

Hash content in one go.

Parameters:

data – The content.

Returns:

The base64 hash.