libquickxor - C implementation of the QuickXorHash
# command line
$ quickxorhash FILE[s]
/* library */
#include <quickxor.h>
pqx = QX_new();
QX_add(pData, size);
QX_readFile(filename);
pDigest = QX_digest(pqx);
pBase64Digest = QX_b64digest(pqx);
QX_reset(pqx);
QX_free(pqx);
libquickxor is the C implementation of the QuickXorHash.
The QuickXorHash is the digest used by Microsoft on Office 365 OneDrive for Business and Sharepoint. It was published by Microsoft in 2016 in form of a C# script. The explanation describes it as a "quick, simple non-cryptographic hash algorithm that works by XORing the bytes in a circular-shifting fashion".
Download the latest version from Github.
wget https://github.com/Tekki/quickxor-c/archive/v0.10.tar.gz -O quickxor-0.10.tar.gz
tar xvzf quickxor-0.10.tar.gz
cd quickxor-c-0.10
A full installation requires automake
and libtool
.
autoreconf --install
./configure
make
make check # optional
sudo make install
sudo ldconfig
If you just need a running binary you can compile it with
cd src
make -f Makefile.simple
quickxorhash FILE[s]
Calculates the QuickXor hash for one or multiple files.
QX* pqx = QX_new();
Returns a pointer to a new QX structure.
/* void QX_add(QX* pqx, uint8_t* addData, size_t addSize) */
uint8_t* addData = ...;
size_t addSize = ...;
QX_add(pqx, addData, addSize);
Adds a new block of data.
/* char* QX_b64digest(QX* pqx) */
char* b64digest = QX_b64digest(pqx);
Returns the Base64 encoded digest for the data. This operation does not affect the data and can be repeated.
/* uint8_t* QX_digest(QX* pqx) */
uint8_t* digest = QX_digest(pqx);
Returns the binary array of the digest for the data. This operation does not affect the data and can be repeated.
/* void QX_free(QX* pqx) */
QX_free(pqx);
Frees the memory reserved for the specified QX.
/* int QX_readFile(QX* pqx, char* filename) */
char filename[] = "a file";
int status = QX_readFile(pqx, filename);
Resets the QX, reads the file and adds its content. Returns 0 on success and 1 if the file could not be read.
/* void QX_reset(QX* pqx) */
QX_reset(pqx);
Resets the QX to its orignal state so it can be used to calculate a new digest.
© 2019 by Tekki (Rolf Stöckli).
© for the original algorithm 2016 by Microsoft.
This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.
Explanation of the QuickXorHash Algorithm in the OneDrive Dev Center.
QuickXorHash.cs by Ryan Gregg.
Digest::QuickXor, Perl implementation.