[Pkg-javascript-commits] [node-browserify-aes] 55/92: Use create-hash to avoid needing DI of crypto
Bastien Roucariès
rouca at moszumanska.debian.org
Sun Jun 4 09:35:19 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-browserify-aes.
commit ddac35c227ab00abab40be9ce0452fab01e03181
Author: Forbes Lindesay <forbes at lindesay.co.uk>
Date: Sun Jan 18 01:04:23 2015 +0000
Use create-hash to avoid needing DI of crypto
---
browser.js | 12 ++++++++++++
index.js | 7 +++++--
package.json | 2 ++
readme.md | 10 ++++++++++
test/index.js | 2 +-
5 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/browser.js b/browser.js
new file mode 100644
index 0000000..c6ff0eb
--- /dev/null
+++ b/browser.js
@@ -0,0 +1,12 @@
+var crypto = {createHash: require('create-hash')};
+var ciphers = require('./encrypter')(crypto);
+exports.createCipher = exports.Cipher = ciphers.createCipher;
+exports.createCipheriv = exports.Cipheriv = ciphers.createCipheriv;
+var deciphers = require('./decrypter')(crypto);
+exports.createDecipher = exports.Decipher = deciphers.createDecipher;
+exports.createDecipheriv = exports.Decipheriv = deciphers.createDecipheriv;
+var modes = require('./modes');
+function getCiphers () {
+ return Object.keys(modes);
+}
+exports.listCiphers = exports.getCiphers = getCiphers;
diff --git a/index.js b/index.js
index 1e258ed..320ce82 100644
--- a/index.js
+++ b/index.js
@@ -1,4 +1,7 @@
var crypto = require('crypto');
-exports.__browserify = require('./inject')
-exports.__browserify(crypto, module.exports);
+exports.createCipher = exports.Cipher = crypto.createCipher;
+exports.createCipheriv = exports.Cipheriv = crypto.createCipheriv;
+exports.createDecipher = exports.Decipher = crypto.createDecipher;
+exports.createDecipheriv = exports.Decipheriv = crypto.createDecipheriv;
+exports.listCiphers = exports.getCiphers = crypto.getCiphers;
diff --git a/package.json b/package.json
index 67f9158..e291820 100644
--- a/package.json
+++ b/package.json
@@ -2,6 +2,7 @@
"name": "browserify-aes",
"version": "0.8.1",
"description": "aes, for browserify",
+ "browser": "browser.js",
"main": "index.js",
"directories": {
"test": "test"
@@ -25,6 +26,7 @@
},
"homepage": "https://github.com/calvinmetcalf/browserify-aes",
"dependencies": {
+ "create-hash": "^1.1.0",
"inherits": "^2.0.1"
},
"devDependencies": {
diff --git a/readme.md b/readme.md
index 04fbf94..7cc416c 100644
--- a/readme.md
+++ b/readme.md
@@ -3,6 +3,16 @@ browserify-aes
[![Build Status](https://travis-ci.org/calvinmetcalf/browserify-aes.svg)](https://travis-ci.org/calvinmetcalf/browserify-aes)
+Node style aes for use in the browser. Implements:
+
+ - createCipher
+ - createCipheriv
+ - createDecipher
+ - createDecipheriv
+ - getCiphers
+
+In node.js, the `crypto` implementation is used, in browsers it falls back to a pure JavaScript implementation.
+
Much of this library has been taken from the aes implementation in [triplesec](https://github.com/keybase/triplesec), a partial derivation of [crypto-js](https://code.google.com/p/crypto-js/).
`EVP_BytesToKey` is a straight up port of the same function from OpenSSL as there is literally no documenation on it beyond it using 'undocumented extensions' for longer keys.
diff --git a/test/index.js b/test/index.js
index 7f91c67..a275768 100644
--- a/test/index.js
+++ b/test/index.js
@@ -1,7 +1,7 @@
var test = require('tape');
var fixtures = require('./fixtures.json');
var _crypto = require('crypto');
-var crypto = require('../');
+var crypto = require('../browser.js');
var modes = require('../modes');
var types = Object.keys(modes);
var ebtk = require('../EVP_BytesToKey');
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-browserify-aes.git
More information about the Pkg-javascript-commits
mailing list