From c2aa7bf38fb30de2d04f87f8e7780e4c768ae6b1 Mon Sep 17 00:00:00 2001 From: Minteck Date: Thu, 20 Jan 2022 13:43:34 +0100 Subject: Initial commit --- modules/uniqueid.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 modules/uniqueid.js (limited to 'modules') diff --git a/modules/uniqueid.js b/modules/uniqueid.js new file mode 100644 index 0000000..cbf4965 --- /dev/null +++ b/modules/uniqueid.js @@ -0,0 +1,11 @@ +const crypto = require('crypto'); + +module.exports = function DocCMSUniqueID(file) { + if (typeof file !== "undefined") { + salt = file; + } else { + salt = crypto.randomBytes(64).toString("hex"); + } + + return parseInt(crypto.createHash("sha512").update(salt, "utf-8").digest("hex").substring(0, 16), 16).toString().substring(0, 18); +} \ No newline at end of file -- cgit