Documentation
¶
Overview ¶
Package quickxorhash implements Microsoft's QuickXorHash, the content hash that SharePoint Online and OneDrive for Business report in a driveItem's file.hashes.quickXorHash field over Microsoft Graph. It lets a client decide whether a local file already matches the copy stored in a document library without downloading it — handy for sync, mirroring, and de-duplication.
QuickXorHash is a 160-bit XOR-based hash defined by Microsoft and described in the OneDrive developer documentation. Graph returns the digest base64-encoded, so pair this package with encoding/base64 to compare:
h := quickxorhash.New()
if _, err := io.Copy(h, f); err != nil {
return err
}
got := base64.StdEncoding.EncodeToString(h.Sum(nil))
// compare got against driveItem.file.hashes.quickXorHash
The value returned by New implements the standard library hash.Hash interface, so it streams and drops in anywhere crypto/sha1 or hash/crc32 would. This is an independent implementation from the published algorithm description and depends only on the standard library.
Index ¶
Examples ¶
Constants ¶
const ( // Size is the length in bytes of a QuickXorHash digest. Size = 20 // BlockSize is the hash's block size in bytes. The algorithm imposes no // real block size; this is the conventional value reported to callers. BlockSize = 64 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
This section is empty.