summaryrefslogtreecommitdiff
path: root/xmake/core/sandbox/modules/hash.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2022-05-19 23:16:35 +0800
committerruki <[email protected]>2022-05-19 23:16:35 +0800
commit7ee3bcea46426a9cc67b5a175f0f4abe0e5dd238 (patch)
tree15b24bc73573ec0d7530d9028e8bf3e3c5ce2442 /xmake/core/sandbox/modules/hash.lua
parent2a3f925f6dd3c3ffd0b4322b2423125dd207b045 (diff)
add xxhash
Diffstat (limited to 'xmake/core/sandbox/modules/hash.lua')
-rw-r--r--xmake/core/sandbox/modules/hash.lua18
1 files changed, 18 insertions, 0 deletions
diff --git a/xmake/core/sandbox/modules/hash.lua b/xmake/core/sandbox/modules/hash.lua
index 95bc4317f..0827f072f 100644
--- a/xmake/core/sandbox/modules/hash.lua
+++ b/xmake/core/sandbox/modules/hash.lua
@@ -66,6 +66,24 @@ function sandbox_hash.md5(file_or_data)
return md5
end
+-- make xxhash64 from the given file or data
+function sandbox_hash.xxhash64(file_or_data)
+ local xxhash64, errors = hash.xxhash64(file_or_data)
+ if not xxhash64 then
+ raise("cannot make xxhash64 for %s, %s", file_or_data, errors or "unknown errors")
+ end
+ return xxhash64
+end
+
+-- make xxhash128 from the given file or data
+function sandbox_hash.xxhash128(file_or_data)
+ local xxhash128, errors = hash.xxhash128(file_or_data)
+ if not xxhash128 then
+ raise("cannot make xxhash128 for %s, %s", file_or_data, errors or "unknown errors")
+ end
+ return xxhash128
+end
+
-- return module
return sandbox_hash