[Pkg-javascript-commits] [node-diffie-hellman] 45/88: browser: cleanup

Bastien Roucariès rouca at moszumanska.debian.org
Thu May 4 10:19:15 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-diffie-hellman.

commit a17303f9963fed65df20913ebb3bdde79b77e4f8
Author: Daniel Cousens <github at dcousens.com>
Date:   Fri Jan 23 15:44:47 2015 +1100

    browser: cleanup
---
 browser.js | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/browser.js b/browser.js
index e3457c5..2152764 100644
--- a/browser.js
+++ b/browser.js
@@ -1,35 +1,40 @@
+var generatePrime = require('./generatePrime');
 var primes = require('./primes.json');
+
 var DH = require('./dh');
-var generatePrime = require('./generatePrime');
 
-exports.DiffieHellmanGroup =
-  exports.createDiffieHellmanGroup =
-  exports.getDiffieHellman = DiffieHellmanGroup;
 function DiffieHellmanGroup(mod) {
-	return new DH(new Buffer(primes[mod].prime, 'hex'),
-		new Buffer(primes[mod].gen, 'hex'));
+  var prime = new Buffer(primes[mod].prime, 'hex')
+  var gen = new Buffer(primes[mod].gen, 'hex')
+
+	return new DH(prime, gen);
 }
-exports.createDiffieHellman = exports.DiffieHellman = DiffieHellman;
+
 function DiffieHellman(prime, enc, generator, genc) {
-	
-	if (Buffer.isBuffer(enc) ||
-		(typeof enc === 'string' && ['hex', 'binary', 'base64'].indexOf(enc) === -1)) {
+	if (Buffer.isBuffer(enc) || (typeof enc === 'string' && ['hex', 'binary', 'base64'].indexOf(enc) === -1)) {
 		genc = generator;
 		generator = enc;
-		enc = void 0;
+		enc = undefined;
 	}
+
 	enc = enc || 'binary';
 	genc = genc || 'binary';
 	generator = generator || new Buffer([2]);
+
 	if (!Buffer.isBuffer(generator)) {
 		generator = new Buffer(generator, genc);
 	}
+
 	if (typeof prime === 'number') {
 		return new DH(generatePrime(prime, generator), generator, true);
 	}
+
 	if (!Buffer.isBuffer(prime)) {
 		prime = new Buffer(prime, enc);
 	}
-	
+
 	return new DH(prime, generator, true);
 }
+
+exports.DiffieHellmanGroup = exports.createDiffieHellmanGroup = exports.getDiffieHellman = DiffieHellmanGroup;
+exports.createDiffieHellman = exports.DiffieHellman = DiffieHellman;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-diffie-hellman.git



More information about the Pkg-javascript-commits mailing list