(feat): improve profile popup in the navbar, add shared code to that popup
This commit is contained in:
parent
7a7ab3ad2e
commit
f4088691c5
4 changed files with 114 additions and 14 deletions
|
|
@ -4,6 +4,7 @@
|
|||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"./code": "./src/code.ts",
|
||||
"./data": "./src/data.ts",
|
||||
"./desktopMedia": "./src/desktopMedia.tsx",
|
||||
"./log": "./src/log.tsx",
|
||||
|
|
|
|||
20
packages/shared/src/code.ts
Normal file
20
packages/shared/src/code.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
export function toLossySixDigitCode(input: string): string {
|
||||
let firstHash = 0xdeadbeef;
|
||||
let secondHash = 0x41c6ce57;
|
||||
|
||||
for (let index = 0; index < input.length; index += 1) {
|
||||
const character = input.charCodeAt(index);
|
||||
|
||||
firstHash = Math.imul(firstHash ^ character, 2654435761);
|
||||
secondHash = Math.imul(secondHash ^ character, 1597334677);
|
||||
}
|
||||
|
||||
firstHash = Math.imul(firstHash ^ (firstHash >>> 16), 2246822507);
|
||||
firstHash ^= Math.imul(secondHash ^ (secondHash >>> 13), 3266489909);
|
||||
secondHash = Math.imul(secondHash ^ (secondHash >>> 16), 2246822507);
|
||||
secondHash ^= Math.imul(firstHash ^ (firstHash >>> 13), 3266489909);
|
||||
|
||||
const hash = 4294967296 * (2097151 & secondHash) + (firstHash >>> 0);
|
||||
|
||||
return String(hash % 1_000_000).padStart(6, "0");
|
||||
}
|
||||
Loading…
Reference in a new issue