Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Javascript implementation of Fernet symmetric encryption https://github.com/kr/fernet-spec
Javascript implementation of Fernet symmetric encryption.
Fernet is an opinionated way of using AES and HMAC authentication that makes shared-secret symmetric encryption simpler for communicating applications.
Fernet.js combines Crypto-JS, sjcl, and browserify to provide a library that works in both node and the browser.
Instead of using TypedArrays I use Hex Strings and CryptoJS's Hex.parse
to build up CryptoJs.lib.WordArray
objects. The Stanford Javscript Crypto
Library is used for pseudo-random number generation.
It's generally never considered safe to encrypt data in the browser.
However, you can use this library to encrypt/decrypt data server-side and decrypt data on a client.
var fernet = require('./fernet');
<script src="fernetBrowser.js"></script>
Sets the secret
at the top level for all further Tokens made
from this instance of Fernet.
Sets the ttl
at the top level for all further Tokens made
from this instance of Fernet.
Generating appropriate secrets is beyond the scope of `Fernet`, but you should
generate it using `/dev/random` in a *nix. To generate a base64-encoded 256 bit
(32 byte) random sequence, try:
dd if=/dev/urandom bs=32 count=1 2>/dev/null | openssl base64
var secret = new fernet.Secret("cw_0x689RpI-jtRR7oE8h_eQsKImvJapLeSbXpwF4e4=");
/*
{
signingKeyHex: '730ff4c7af3d46923e8ed451ee813c87',
signingKey: [CryptoJS.lib.WordArray],
encryptionKeyHex: 'f790b0a226bc96a92de49b5e9c05e1ee',
encryptionKey: [CryptoJS.lib.WordArray]
}
*/
Options:
secret
: a fernet.Secret
objecttoken
: a Fernet-encoded Stringttl
: seconds of ttlFor testing:
time
: Date objectiv
: Array of Integers//Have to include time and iv to make it deterministic.
//Normally time would default to (new Date()) and iv to something random.
var token = new fernet.Token({
secret: secret,
time: Date.parse(1),
iv: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
})
token.encode("Message")
/*
'gAAAAABSO_yhAAECAwQFBgcICQoLDA0OD1PGoFV6wgWZG6AOBfQqevwJT2qKtCZ0EjKy1_TvyxTseR_3ebIF6Ph-xa2QT_tEvg=='
*/
Include tt
var token = new fernet.Token({
secret: secret,
token: 'gAAAAABSO_yhAAECAwQFBgcICQoLDA0OD1PGoFV6wgWZG6AOBfQqevwJT2qKtCZ0EjKy1_TvyxTseR_3ebIF6Ph-xa2QT_tEvg==',
ttl: 0
})
token.decode();
/*
"Message"
*/
> npm test
Compiles new fernetBrowser.js via browserify
,
tests node lib with mocha
, then opens test.html via open
.
FAQs
Javascript implementation of Fernet symmetric encryption https://github.com/kr/fernet-spec
The npm package fernet receives a total of 6,279 weekly downloads. As such, fernet popularity was classified as popular.
We found that fernet demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.