Skip to content

Instantly share code, notes, and snippets.

@holyshared
Last active July 4, 2020 14:17
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 holyshared/407cb741abffd85ce76470d1ca1ce330 to your computer and use it in GitHub Desktop.
Save holyshared/407cb741abffd85ce76470d1ca1ce330 to your computer and use it in GitHub Desktop.
node_modules
const fernet = require('fernet');
const secret = new fernet.Secret('b2tnb29nbGVva2dvb2dsZW9rZ29vZ2xlb2tnb29nbGU=');
const token = new fernet.Token({
secret,
time: new Date,
ttl: 1
});
const encoded = token.encode(JSON.stringify({ name: 'a' }));
console.log(encoded);
const decoded = token.decode(encoded);
console.log(decoded);
setTimeout(() => {
const decoded = token.decode(encoded);
console.log(decoded);
}, 500);
{
"dependencies": {
"fernet": "^0.3.1"
}
}
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
crypto-js@~3.1.2-1:
version "3.1.8"
resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-3.1.8.tgz#715f070bf6014f2ae992a98b3929258b713f08d5"
integrity sha1-cV8HC/YBTyrpkqmLOSkli3E/CNU=
fernet@^0.3.1:
version "0.3.1"
resolved "https://registry.yarnpkg.com/fernet/-/fernet-0.3.1.tgz#970ea51dddc34a77b8805961e05758826a9eca29"
integrity sha512-7KnsrcpLkUsKy6aH6Ow68hrMWhvE25rTDd3370+xVGkpqZta05cUCmdJQPyLBKTsNdPUB5NumJZBgJIJ60aQqw==
dependencies:
crypto-js "~3.1.2-1"
urlsafe-base64 "1.0.0"
urlsafe-base64@1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/urlsafe-base64/-/urlsafe-base64-1.0.0.tgz#23f89069a6c62f46cf3a1d3b00169cefb90be0c6"
integrity sha1-I/iQaabGL0bPOh07ABac77kL4MY=
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment