Skip to content

Instantly share code, notes, and snippets.

@JLarky
Last active December 21, 2023 07:15
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/0d61cf5c4e787a2849db7fb4726b4716 to your computer and use it in GitHub Desktop.
Save JLarky/0d61cf5c4e787a2849db7fb4726b4716 to your computer and use it in GitHub Desktop.
This code doesn't work in Deno and Bun ;(
- output
bun image
deno image
node image
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.assert(payload.sub === "johndoe");
console.log(payload);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment