Skip to content

Instantly share code, notes, and snippets.

@alessioalex
Forked from yetanotherchris/sjcl-example.js
Created July 11, 2018 12:52
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 alessioalex/78e6aa10388cd6b20176e547b069fc7e to your computer and use it in GitHub Desktop.
Save alessioalex/78e6aa10388cd6b20176e547b069fc7e to your computer and use it in GitHub Desktop.
Stanford Javascript Crypto Library basic AES example
// Basic AES example using the defaults.
// https://github.com/bitwiseshiftleft/sjcl
var password = "password";
var text = "my secret text";
var parameters = { "iter" : 1000 };
var rp = {};
var cipherTextJson = {};
sjcl.misc.cachedPbkdf2(password, parameters);
cipherTextJson = sjcl.encrypt(password, text, parameters, rp);
console.log(cipherTextJson);
var decryptedText = sjcl.decrypt(password, cipherTextJson)
console.log(decryptedText);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment