mirror of
https://github.com/abraunegg/onedrive
synced 2024-05-01 13:42:53 +02:00
QuickXor utility function
This commit is contained in:
parent
a2298be257
commit
f19b86e4c7
13
src/util.d
13
src/util.d
|
@ -1,3 +1,4 @@
|
|||
import std.base64;
|
||||
import std.conv;
|
||||
import std.digest.crc;
|
||||
import std.file;
|
||||
|
@ -7,6 +8,7 @@ import std.regex;
|
|||
import std.socket;
|
||||
import std.stdio;
|
||||
import std.string;
|
||||
import qxor;
|
||||
|
||||
private string deviceName;
|
||||
|
||||
|
@ -50,6 +52,17 @@ string computeCrc32(string path)
|
|||
return crc.finish().toHexString().dup;
|
||||
}
|
||||
|
||||
// return the quickXorHash base64 string of a file
|
||||
string computeQuickXorHash(string path)
|
||||
{
|
||||
QuickXor qxor;
|
||||
auto file = File(path, "rb");
|
||||
foreach (ubyte[] data; chunks(file, 4096)) {
|
||||
qxor.put(data);
|
||||
}
|
||||
return Base64.encode(qxor.finish());
|
||||
}
|
||||
|
||||
// convert wildcards (*, ?) to regex
|
||||
Regex!char wild2regex(const(char)[] pattern)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue