Skip to content

Instantly share code, notes, and snippets.

@JLarky
Created December 21, 2023 07:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JLarky/70ff6a86ae20c7dc4541572919963121 to your computer and use it in GitHub Desktop.
Save JLarky/70ff6a86ae20c7dc4541572919963121 to your computer and use it in GitHub Desktop.
This code doesn't work in Deno and
import { V3 } from "paseto"; // or "npm:paseto";
const key = await V3.generateKey("local", { format: "paserk" });
console.assert(key.length === 52);
console.log(key);
const obj = await V3.encrypt({ sub: "johndoe" }, key);
console.log(obj);
const payload = await V3.decrypt(obj, key);
console.log(payload);
console.assert(payload.sub === "johndoe");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment