2021-12-08 19:32:58 +05:00
|
|
|
import { hash, SALT_LENGTH } from "@stablelib/blake2s";
|
2021-02-20 11:31:44 +05:00
|
|
|
import SparkMD5 from "spark-md5";
|
2021-06-04 09:32:13 +05:00
|
|
|
import { USER_PERSONALIZATION_HASH } from "../common";
|
|
|
|
|
import { randomBytes } from "./random";
|
2020-08-27 13:13:43 +05:00
|
|
|
|
|
|
|
|
export default function () {
|
2021-06-04 09:32:13 +05:00
|
|
|
const bytes = randomBytes(64);
|
|
|
|
|
const salt = randomBytes(SALT_LENGTH);
|
|
|
|
|
return Buffer.from(
|
|
|
|
|
hash(bytes, 12, { salt, personalization: USER_PERSONALIZATION_HASH })
|
|
|
|
|
).toString("hex");
|
2020-08-27 13:13:43 +05:00
|
|
|
}
|
2021-02-20 11:31:44 +05:00
|
|
|
|
|
|
|
|
export function makeId(text) {
|
|
|
|
|
return SparkMD5.hash(text);
|
|
|
|
|
}
|