summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/sha256.js32
1 files changed, 1 insertions, 31 deletions
diff --git a/common/sha256.js b/common/sha256.js
index 5149f97..13c8c7c 100644
--- a/common/sha256.js
+++ b/common/sha256.js
@@ -36,10 +36,7 @@ if (root.JS_SHA256_NO_WINDOW) {
WINDOW = false;
}
var WEB_WORKER = !WINDOW && typeof self === 'object';
-var NODE_JS = !root.JS_SHA256_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node;
-if (NODE_JS) {
- root = global;
-} else if (WEB_WORKER) {
+if (WEB_WORKER) {
root = self;
}
var COMMON_JS = !root.JS_SHA256_NO_COMMON_JS && typeof module === 'object' && module.exports;
@@ -82,9 +79,6 @@ var createOutputMethod = function (outputType, is224) {
var createMethod = function (is224) {
var method = createOutputMethod('hex', is224);
- if (NODE_JS) {
- method = nodeWrap(method, is224);
- }
method.create = function () {
return new Sha256(is224);
};
@@ -98,30 +92,6 @@ var createMethod = function (is224) {
return method;
};
-var nodeWrap = function (method, is224) {
- var crypto = eval("require('crypto')");
- var Buffer = eval("require('buffer').Buffer");
- var algorithm = is224 ? 'sha224' : 'sha256';
- var nodeMethod = function (message) {
- if (typeof message === 'string') {
- return crypto.createHash(algorithm).update(message, 'utf8').digest('hex');
- } else {
- if (message === null || message === undefined) {
- throw new Error(ERROR);
- } else if (message.constructor === ArrayBuffer) {
- message = new Uint8Array(message);
- }
- }
- if (Array.isArray(message) || ArrayBuffer.isView(message) ||
- message.constructor === Buffer) {
- return crypto.createHash(algorithm).update(new Buffer(message)).digest('hex');
- } else {
- return method(message);
- }
- };
- return nodeMethod;
-};
-
var createHmacOutputMethod = function (outputType, is224) {
return function (key, message) {
return new HmacSha256(key, is224, true).update(message)[outputType]();