blob: f0494e98a2c8485218c7e29ec40a3e79ced31fbd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
const crypto = require('crypto');
module.exports = function DocCMSUniqueID(file) {
if (typeof file !== "undefined") {
salt = file;
} else {
salt = crypto.randomBytes(64).toString("hex");
}
switch (config.pages_id_generator) {
case "snowflake":
default:
return parseInt(crypto.createHash("sha512").update(salt, "utf-8").digest("hex").substring(0, 16), 16).toString().substring(0, 18);
case "md5":
return crypto.createHash("md5").update(salt, "utf-8").digest("hex");
case "sha256":
return crypto.createHash("sha256").update(salt, "utf-8").digest("hex");
}
}
|