MCPcopy Create free account
hub / github.com/HKUDS/AgentSpace / buildDeterministicJoinCode

Function buildDeterministicJoinCode

packages/db/src/database.ts:642–655  ·  view source on GitHub ↗
(seed: string)

Source from the content-addressed store, hash-verified

640}
641
642function buildDeterministicJoinCode(seed: string): string {
643 const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
644 let hash = 2166136261;
645 for (const char of seed) {
646 hash ^= char.charCodeAt(0);
647 hash = Math.imul(hash, 16777619);
648 }
649 let code = "";
650 for (let index = 0; index < 8; index += 1) {
651 hash = Math.imul(hash ^ index, 16777619);
652 code += alphabet[Math.abs(hash) % alphabet.length];
653 }
654 return code;
655}
656
657function seedDefaultWorkspace(db: PostgresSyncDatabase): void {
658 const existingWorkspace = db.prepare("SELECT 1 FROM workspace WHERE id = ? LIMIT 1").get(DEFAULT_WORKSPACE_ID);

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected