Quickstart
This illustrative example creates a prefixed key and its digest, then stores the digest. Give the plaintext key only to its authorized recipient, once:
import { generateKeyAndHash } from "@fungi.computer/one-key";
// Stand-in for the credential owner's real storage operation. One Key does// not provide storage.async function storeCredentialDigest(digest: string): Promise<void> { console.log("store this digest:", digest);}
const { key, digest } = await generateKeyAndHash({ prefix: "invite" });await storeCredentialDigest(digest);console.log("send this key to its recipient once:", key);The existing tests verify that a generated digest matches the plaintext key in
test/crypto.test.ts.