s365b.modules.onedrive.quickxor =============================== .. py:module:: s365b.modules.onedrive.quickxor .. autoapi-nested-parse:: 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 ---------- .. autoapisummary:: s365b.modules.onedrive.quickxor.WIDTH s365b.modules.onedrive.quickxor.BLOCK s365b.modules.onedrive.quickxor.SHIFT Classes ------- .. autoapisummary:: s365b.modules.onedrive.quickxor.QuickXorHash Functions --------- .. autoapisummary:: s365b.modules.onedrive.quickxor.quick_xor_hash Module Contents --------------- .. py:data:: WIDTH :value: 160 .. py:data:: BLOCK :value: 160 .. py:data:: SHIFT :value: 11 .. py:class:: QuickXorHash Incremental QuickXorHash: :meth:`update` with each piece, then :meth:`digest`. .. py:attribute:: length :value: 0 .. py:method:: update(data: bytes) -> None Add the next piece of content. :param data: Bytes following those already added. .. py:method:: digest() -> bytes The 20-byte hash of everything added so far. :returns: The hash. .. py:method:: b64digest() -> str The hash in base64, as Graph gives it (``file.hashes.quickXorHash``). :returns: The hash. .. py:function:: quick_xor_hash(data: bytes) -> str Hash content in one go. :param data: The content. :returns: The base64 hash.