made with esnextbin
Last active
May 6, 2016 03:46
-
-
Save dreid/06fd283b092fb1504481a6580a91ba97 to your computer and use it in GitHub Desktop.
esnextbin sketch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>ESNextbin Sketch</title> | |
<!-- put additional styles and scripts here --> | |
</head> | |
<body> | |
<!-- put markup and other contents here --> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// write ES2015 code and import modules from npm | |
// and then press "Execute" to run your program | |
class Fernet { | |
constructor(key) { | |
this.key = key; | |
} | |
}; | |
Fernet.generateKey = function generateKey() { | |
return window.crypto.subtle.generateKey( | |
{ | |
name: "AES-CBC", | |
length: 128, //can be 128, 192, or 256 | |
}, | |
false, //whether the key is extractable (i.e. can be used in exportKey) | |
["encrypt", "decrypt"] //can be "encrypt", "decrypt", "wrapKey", or "unwrapKey" | |
); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "esnextbin-sketch", | |
"version": "0.0.0", | |
"dependencies": { | |
"babel-runtime": "6.6.1" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck"); | |
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
// write ES2015 code and import modules from npm | |
// and then press "Execute" to run your program | |
var Fernet = function Fernet(key) { | |
(0, _classCallCheck3.default)(this, Fernet); | |
this.key = key; | |
}; | |
; | |
Fernet.generateKey = function generateKey() { | |
return window.crypto.subtle.generateKey({ | |
name: "AES-CBC", | |
length: 128 }, //can be 128, 192, or 256 | |
false, //whether the key is extractable (i.e. can be used in exportKey) | |
["encrypt", "decrypt"] //can be "encrypt", "decrypt", "wrapKey", or "unwrapKey" | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment