21 lines
667 B
TypeScript
21 lines
667 B
TypeScript
import { encodeBase64 } from "https://deno.land/std@0.222.1/encoding/base64.ts";
|
|
|
|
export async function is_relevant(text: string) {
|
|
return (await hash(text)) === relevant_hash;
|
|
}
|
|
|
|
async function hash(namespace: string) {
|
|
const buffer = new TextEncoder().encode(namespace);
|
|
const hash = await crypto.subtle.digest("SHA-512", buffer);
|
|
const base64 = encodeBase64(hash);
|
|
return base64;
|
|
}
|
|
|
|
const relevant_hash = "Qa4xy8yRPnBsQf8U2UUE7tse2u4Fi/Aqxbt" +
|
|
"6aq56m5ofcmCkTi8PbgMBF1OtHC6qkXDF2tz2qKprYCIAMzTSQQ==";
|
|
|
|
Deno.test("encode_namespace", async () => {
|
|
const namespace = "CHANGEME";
|
|
const base64 = await hash(namespace);
|
|
console.log({ namespace, base64 });
|
|
});
|