Skip to content

Instantly share code, notes, and snippets.

@mraleson
mraleson / fernet.js
Last active March 14, 2024 16:24
Untested Javascript Fernet Decrypt
const crypto = require('crypto');
function base64UrlDecode(value) {
const translated = value.replace(/-/g, '+').replace(/_/g, '/');
const padding = translated.length % 4;
const padded = translated + '='.repeat(padding);
return Buffer.from(padded, 'base64');
}
function decrypt(secret, token, ttl) {