pax_global_header 0000666 0000000 0000000 00000000064 14705755022 0014521 g ustar 00root root 0000000 0000000 52 comment=55476aca92a99c81fcc438519a4d55817fb455fc browserify-crypto-browserify-ab8920b/ 0000775 0000000 0000000 00000000000 14705755022 0020034 5 ustar 00root root 0000000 0000000 browserify-crypto-browserify-ab8920b/.eslintrc 0000664 0000000 0000000 00000000443 14705755022 0021661 0 ustar 00root root 0000000 0000000 { "root": true, "extends": "@ljharb", "rules": { "func-style": "off", "multiline-comment-style": "off", "sort-keys": "off", }, "ignorePatterns": [ "example/bundle.js", ], "overrides": [ { "files": "example/**", "rules": { "no-console": "off", }, }, ], } browserify-crypto-browserify-ab8920b/.github/ 0000775 0000000 0000000 00000000000 14705755022 0021374 5 ustar 00root root 0000000 0000000 browserify-crypto-browserify-ab8920b/.github/FUNDING.yml 0000664 0000000 0000000 00000001114 14705755022 0023206 0 ustar 00root root 0000000 0000000 # These are supported funding model platforms github: [ljharb] patreon: # Replace with a single Patreon username open_collective: # Replace with a single Open Collective username ko_fi: # Replace with a single Ko-fi username tidelift: npm/crypto-browserify community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username otechie: # Replace with a single Otechie username custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] browserify-crypto-browserify-ab8920b/.github/workflows/ 0000775 0000000 0000000 00000000000 14705755022 0023431 5 ustar 00root root 0000000 0000000 browserify-crypto-browserify-ab8920b/.github/workflows/node-aught.yml 0000664 0000000 0000000 00000000364 14705755022 0026212 0 ustar 00root root 0000000 0000000 name: 'Tests: node.js < 10' on: [pull_request, push] jobs: tests: uses: ljharb/actions/.github/workflows/node.yml@main with: range: '>= 0.10 < 10' type: minors command: npm run tests-only skip-ls-check: true browserify-crypto-browserify-ab8920b/.github/workflows/node-pretest.yml 0000664 0000000 0000000 00000000345 14705755022 0026567 0 ustar 00root root 0000000 0000000 name: 'Tests: pretest/posttest' on: [pull_request, push] jobs: tests: uses: ljharb/actions/.github/workflows/pretest.yml@main with: skip-engines: true # see https://github.com/browserify/browserify-sign/pull/49 browserify-crypto-browserify-ab8920b/.github/workflows/node-tens.yml 0000664 0000000 0000000 00000000324 14705755022 0026047 0 ustar 00root root 0000000 0000000 name: 'Tests: node.js >= 10' on: [pull_request, push] jobs: tests: uses: ljharb/actions/.github/workflows/node.yml@main with: range: '>= 10' type: minors command: npm run tests-only browserify-crypto-browserify-ab8920b/.github/workflows/rebase.yml 0000664 0000000 0000000 00000000257 14705755022 0025421 0 ustar 00root root 0000000 0000000 name: Automatic Rebase on: [pull_request_target] jobs: _: uses: ljharb/actions/.github/workflows/rebase.yml@main secrets: token: ${{ secrets.GITHUB_TOKEN }} browserify-crypto-browserify-ab8920b/.github/workflows/require-allow-edits.yml 0000664 0000000 0000000 00000000303 14705755022 0030046 0 ustar 00root root 0000000 0000000 name: Require “Allow Edits” on: [pull_request_target] jobs: _: name: "Require “Allow Edits”" runs-on: ubuntu-latest steps: - uses: ljharb/require-allow-edits@main browserify-crypto-browserify-ab8920b/.gitignore 0000664 0000000 0000000 00000000205 14705755022 0022021 0 ustar 00root root 0000000 0000000 # gitignore node_modules # Only apps should have lockfiles npm-shrinkwrap.json package-lock.json yarn.lock coverage/ .nyc_output/ browserify-crypto-browserify-ab8920b/.npmrc 0000664 0000000 0000000 00000000050 14705755022 0021147 0 ustar 00root root 0000000 0000000 package-lock=false audit-level=moderate browserify-crypto-browserify-ab8920b/.nycrc 0000664 0000000 0000000 00000000121 14705755022 0021145 0 ustar 00root root 0000000 0000000 { "exclude": [ "test/**" ], "reporter": [ "html", "text" ] } browserify-crypto-browserify-ab8920b/.travis.yml 0000664 0000000 0000000 00000001652 14705755022 0022151 0 ustar 00root root 0000000 0000000 sudo: false language: node_js matrix: include: env: TEST_SUITE=browser BROWSER_NAME=ie BROWSER_VERSION="10..latest" - node_js: '4' env: TEST_SUITE=browser BROWSER_NAME=chrome BROWSER_VERSION="-2..beta" - node_js: '4' env: TEST_SUITE=browser BROWSER_NAME=firefox BROWSER_VERSION="-2..latest" - node_js: '4' env: TEST_SUITE=browser BROWSER_NAME=safari BROWSER_VERSION="7..latest" - node_js: '4' env: TEST_SUITE=browser BROWSER_NAME=android BROWSER_VERSION="5.0..latest" script: "npm run-script $TEST_SUITE" env: global: - secure: YHNUDQmx/WiW3gmDcRCfb6KLDeio7Mr5tqPY2kHPdZlBSytsQjNk75ytM4U6Cu8Uk8iEIoj/aFlxiVMpJNA8J4QSUyW/YkbVaIz0+1oywoV0Ht8aRBfZ1jvXfX6789+1Q9c4xaMkYYbJpXSh9JcirsiwmqWd4+IDd7hcESodsDQ= - secure: Nhj5yejKZxUbtHGZta+GjYWqXGaOZB7ainTkOuGcpXM+OwwjeDpYlTBrwS90Q7hqens7KXVzQM09aDbadpsDCsOo1nyaEigMtomAorZ1UC1CpEoVz1ZuikF9bEhb+/7M9pzuL1fX+Ke9Dx4mPPeb8sf/2SrAu1RqXkSwZV/duAc= browserify-crypto-browserify-ab8920b/LICENSE 0000664 0000000 0000000 00000002077 14705755022 0021047 0 ustar 00root root 0000000 0000000 The MIT License Copyright (c) 2013 Dominic Tarr Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. browserify-crypto-browserify-ab8920b/README.md 0000664 0000000 0000000 00000005335 14705755022 0021321 0 ustar 00root root 0000000 0000000 # crypto-browserify [![Version Badge][npm-version-svg]][package-url] A port of node's `crypto` module to the browser. [![github actions][actions-image]][actions-url] [![coverage][codecov-image]][codecov-url] [![License][license-image]][license-url] [![Downloads][downloads-image]][downloads-url] [](https://saucelabs.com/u/crypto-browserify) [![npm badge][npm-badge-png]][package-url] The goal of this module is to reimplement node's crypto module, in pure javascript so that it can run in the browser. Here is the subset that is currently implemented: * createHash (sha1, sha224, sha256, sha384, sha512, md5, rmd160) * createHmac (sha1, sha224, sha256, sha384, sha512, md5, rmd160) * pbkdf2 * pbkdf2Sync * randomBytes * pseudoRandomBytes * createCipher (aes) * createDecipher (aes) * createDiffieHellman * createSign (rsa, ecdsa) * createVerify (rsa, ecdsa) * createECDH (secp256k1) * publicEncrypt/privateDecrypt (rsa) * privateEncrypt/publicDecrypt (rsa) ## todo these features from node's `crypto` are still unimplemented. * createCredentials ## contributions If you are interested in writing a feature, please implement as a new module, which will be incorporated into crypto-browserify as a dependency. All deps must be compatible with node's crypto (generate example inputs and outputs with node, and save base64 strings inside JSON, so that tests can run in the browser) see [sha.js](https://github.com/dominictarr/sha.js) Crypto is _extra serious_ so please do not hesitate to review the code, and post comments if you do. ## License MIT [package-url]: https://npmjs.org/package/crypto-browserify [npm-version-svg]: https://versionbadg.es/browserify/crypto-browserify.svg [deps-svg]: https://david-dm.org/browserify/crypto-browserify.svg [deps-url]: https://david-dm.org/browserify/crypto-browserify [dev-deps-svg]: https://david-dm.org/browserify/crypto-browserify/dev-status.svg [dev-deps-url]: https://david-dm.org/browserify/crypto-browserify#info=devDependencies [npm-badge-png]: https://nodei.co/npm/crypto-browserify.png?downloads=true&stars=true [license-image]: https://img.shields.io/npm/l/crypto-browserify.svg [license-url]: LICENSE [downloads-image]: https://img.shields.io/npm/dm/crypto-browserify.svg [downloads-url]: https://npm-stat.com/charts.html?package=crypto-browserify [codecov-image]: https://codecov.io/gh/browserify/crypto-browserify/branch/main/graphs/badge.svg [codecov-url]: https://app.codecov.io/gh/browserify/crypto-browserify/ [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/browserify/crypto-browserify [actions-url]: https://github.com/browserify/crypto-browserify/actions browserify-crypto-browserify-ab8920b/example/ 0000775 0000000 0000000 00000000000 14705755022 0021467 5 ustar 00root root 0000000 0000000 browserify-crypto-browserify-ab8920b/example/bundle.js 0000664 0000000 0000000 00000037651 14705755022 0023312 0 ustar 00root root 0000000 0000000 'use strict'; var require = function (file, cwd) { var resolved = require.resolve(file, cwd || '/'); var mod = require.modules[resolved]; if (!mod) { throw new Error('Failed to resolve module ' + file + ', tried ' + resolved); } var res = mod._cached ? mod._cached : mod(); return res; }; require.paths = []; require.modules = {}; require.extensions = ['.js', '.coffee']; require._core = { assert: true, events: true, fs: true, path: true, vm: true }; require.resolve = (function () { return function (x, cwd) { if (!cwd) { cwd = '/'; } if (require._core[x]) { return x; } var path = require.modules.path(); cwd = path.resolve('/', cwd); var y = cwd || '/'; if (x.match(/^(?:\.\.?\/|\/)/)) { var m = loadAsFileSync(path.resolve(y, x)) || loadAsDirectorySync(path.resolve(y, x)); if (m) { return m; } } var n = loadNodeModulesSync(x, y); if (n) { return n; } throw new Error("Cannot find module '" + x + "'"); function loadAsFileSync(x) { if (require.modules[x]) { return x; } for (var i = 0; i < require.extensions.length; i++) { var ext = require.extensions[i]; if (require.modules[x + ext]) { return x + ext; } } } function loadAsDirectorySync(x) { x = x.replace(/\/+$/, ''); var pkgfile = x + '/package.json'; if (require.modules[pkgfile]) { var pkg = require.modules[pkgfile](); var b = pkg.browserify; if (typeof b === 'object' && b.main) { var m = loadAsFileSync(path.resolve(x, b.main)); if (m) { return m; } } else if (typeof b === 'string') { var m = loadAsFileSync(path.resolve(x, b)); if (m) { return m; } } else if (pkg.main) { var m = loadAsFileSync(path.resolve(x, pkg.main)); if (m) { return m; } } } return loadAsFileSync(x + '/index'); } function loadNodeModulesSync(x, start) { var dirs = nodeModulesPathsSync(start); for (var i = 0; i < dirs.length; i++) { var dir = dirs[i]; var m = loadAsFileSync(dir + '/' + x); if (m) { return m; } var n = loadAsDirectorySync(dir + '/' + x); if (n) { return n; } } var m = loadAsFileSync(x); if (m) { return m; } } function nodeModulesPathsSync(start) { var parts; if (start === '/') { parts = ['']; } else { parts = path.normalize(start).split('/'); } var dirs = []; for (var i = parts.length - 1; i >= 0; i--) { if (parts[i] === 'node_modules') { continue; } var dir = parts.slice(0, i + 1).join('/') + '/node_modules'; dirs.push(dir); } return dirs; } }; }()); require.alias = function (from, to) { var path = require.modules.path(); var res = null; try { res = require.resolve(from + '/package.json', '/'); } catch (err) { res = require.resolve(from, '/'); } var basedir = path.dirname(res); var keys = (Object.keys || function (obj) { var res = []; for (var key in obj) { res.push(key); } return res; })(require.modules); for (var i = 0; i < keys.length; i++) { var key = keys[i]; if (key.slice(0, basedir.length + 1) === basedir + '/') { var f = key.slice(basedir.length); require.modules[to + f] = require.modules[basedir + f]; } else if (key === basedir) { require.modules[to] = require.modules[basedir]; } } }; require.define = function (filename, fn) { var dirname = require._core[filename] ? '' : require.modules.path().dirname(filename); var require_ = function (file) { return require(file, dirname); }; require_.resolve = function (name) { return require.resolve(name, dirname); }; require_.modules = require.modules; require_.define = require.define; var module_ = { exports: {} }; require.modules[filename] = function () { require.modules[filename]._cached = module_.exports; fn.call( module_.exports, require_, module_, module_.exports, dirname, filename ); require.modules[filename]._cached = module_.exports; return module_.exports; }; }; if (typeof process === 'undefined') { process = {}; } if (!process.nextTick) { process.nextTick = (function () { var queue = []; var canPost = typeof window !== 'undefined' && window.postMessage && window.addEventListener; if (canPost) { window.addEventListener('message', function (ev) { if (ev.source === window && ev.data === 'browserify-tick') { ev.stopPropagation(); if (queue.length > 0) { var fn = queue.shift(); fn(); } } }, true); } return function (fn) { if (canPost) { queue.push(fn); window.postMessage('browserify-tick', '*'); } else { setTimeout(fn, 0); } }; }()); } if (!process.title) { process.title = 'browser'; } if (!process.binding) { process.binding = function (name) { if (name === 'evals') { return require('vm'); } throw new Error('No such module'); }; } if (!process.cwd) { process.cwd = function () { return '.'; }; } if (!process.env) { process.env = {}; } if (!process.argv) { process.argv = []; } require.define('path', function (require, module, exports, __dirname, __filename) { function filter(xs, fn) { var res = []; for (var i = 0; i < xs.length; i++) { if (fn(xs[i], i, xs)) { res.push(xs[i]); } } return res; } // resolves . and .. elements in a path array with directory names there // must be no slashes, empty elements, or device names (c:\) in the array // (so also no leading and trailing slashes - it does not distinguish // relative and absolute paths) function normalizeArray(parts, allowAboveRoot) { // if the path tries to go above the root, `up` ends up > 0 var up = 0; for (var i = parts.length; i >= 0; i--) { var last = parts[i]; if (last == '.') { parts.splice(i, 1); } else if (last === '..') { parts.splice(i, 1); up++; } else if (up) { parts.splice(i, 1); up--; } } // if the path is allowed to go above the root, restore leading ..s if (allowAboveRoot) { for (; up--; up) { parts.unshift('..'); } } return parts; } // Regex to split a filename into [*, dir, basename, ext] // posix version var splitPathRe = /^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/; // path.resolve([from ...], to) // posix version exports.resolve = function () { var resolvedPath = '', resolvedAbsolute = false; for (var i = arguments.length; i >= -1 && !resolvedAbsolute; i--) { var path = i >= 0 ? arguments[i] : process.cwd(); // Skip empty and invalid entries if (typeof path !== 'string' || !path) { continue; } resolvedPath = path + '/' + resolvedPath; resolvedAbsolute = path.charAt(0) === '/'; } // At this point the path should be resolved to a full absolute path, but // handle relative paths to be safe (might happen when process.cwd() fails) // Normalize the path resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function (p) { return !!p; }), !resolvedAbsolute).join('/'); return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.'; }; // path.normalize(path) // posix version exports.normalize = function (path) { var isAbsolute = path.charAt(0) === '/', trailingSlash = path.slice(-1) === '/'; // Normalize the path path = normalizeArray(filter(path.split('/'), function (p) { return !!p; }), !isAbsolute).join('/'); if (!path && !isAbsolute) { path = '.'; } if (path && trailingSlash) { path += '/'; } return (isAbsolute ? '/' : '') + path; }; // posix version exports.join = function () { var paths = Array.prototype.slice.call(arguments, 0); return exports.normalize(filter(paths, function (p, index) { return p && typeof p === 'string'; }).join('/')); }; exports.dirname = function (path) { var dir = splitPathRe.exec(path)[1] || ''; var isWindows = false; if (!dir) { // No dirname return '.'; } else if ( dir.length === 1 || (isWindows && dir.length <= 3 && dir.charAt(1) === ':') ) { // It is just a slash or a drive letter with a slash return dir; } // It is a full dirname, strip trailing slash return dir.substring(0, dir.length - 1); }; exports.basename = function (path, ext) { var f = splitPathRe.exec(path)[2] || ''; // TODO: make this comparison case-insensitive on windows? if (ext && f.substr(-1 * ext.length) === ext) { f = f.substr(0, f.length - ext.length); } return f; }; exports.extname = function (path) { return splitPathRe.exec(path)[3] || ''; }; }); require.define('crypto', function (require, module, exports, __dirname, __filename) { module.exports = require('crypto-browserify'); }); require.define('/node_modules/crypto-browserify/package.json', function (require, module, exports, __dirname, __filename) { module.exports = {}; }); require.define('/node_modules/crypto-browserify/index.js', function (require, module, exports, __dirname, __filename) { var sha = require('./sha'); var algorithms = { sha1: { hex: sha.hex_sha1, binary: sha.b64_sha1, ascii: sha.str_sha1 } }; function error() { var m = Array.prototype.slice.call(arguments).join(' '); throw new Error(m+'\nwe accept pull requests\nhttp://github.com/browserify/crypto-browserify'.join('\n')); } exports.createHash = function (alg) { alg = alg || 'sha1'; if (!algorithms[alg]) { error('algorithm:', alg, 'is not yet supported'); } var s = ''; _alg = algorithms[alg]; return { update: function (data) { s += data; return this; }, digest: function (enc) { enc = enc || 'binary'; var fn; if (!(fn = _alg[enc])) { error('encoding:', enc, 'is not yet supported for algorithm', alg); } var r = fn(s); s = null; // not meant to use the hash after you've called digest. return r; } }; } // the least I can do is make error messages for the rest of the node.js/crypto api. ;[ 'createCredentials', 'createHmac', 'createCypher', 'createCypheriv', 'createDecipher', 'createDecipheriv', 'createSign', 'createVerify', 'createDeffieHellman',, 'pbkdf2',, 'randomBytes' ].forEach(function (name) { exports[name] = function () { error('sorry,', name, 'is not implemented yet'); }; }); }); require.define('/node_modules/crypto-browserify/sha.js', function (require, module, exports, __dirname, __filename) { /* * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined * in FIPS PUB 180-1 * Version 2.1a Copyright Paul Johnston 2000 - 2002. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet * Distributed under the BSD License * See http://pajhome.org.uk/crypt/md5 for details. */ exports.hex_sha1 = hex_sha1; exports.b64_sha1 = b64_sha1; exports.str_sha1 = str_sha1; exports.hex_hmac_sha1 = hex_hmac_sha1; exports.b64_hmac_sha1 = b64_hmac_sha1; exports.str_hmac_sha1 = str_hmac_sha1; /* * Configurable variables. You may need to tweak these to be compatible with * the server-side, but the defaults work in most cases. */ var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */ var b64pad = ''; /* base-64 pad character. "=" for strict RFC compliance */ var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */ /* * These are the functions you'll usually want to call * They take string arguments and return either hex or base-64 encoded strings */ function hex_sha1(s) { return binb2hex(core_sha1(str2binb(s), s.length * chrsz)); } function b64_sha1(s) { return binb2b64(core_sha1(str2binb(s), s.length * chrsz)); } function str_sha1(s) { return binb2str(core_sha1(str2binb(s), s.length * chrsz)); } function hex_hmac_sha1(key, data) { return binb2hex(core_hmac_sha1(key, data)); } function b64_hmac_sha1(key, data) { return binb2b64(core_hmac_sha1(key, data)); } function str_hmac_sha1(key, data) { return binb2str(core_hmac_sha1(key, data)); } /* * Perform a simple self-test to see if the VM is working */ function sha1_vm_test() { return hex_sha1('abc') == 'a9993e364706816aba3e25717850c26c9cd0d89d'; } /* * Calculate the SHA-1 of an array of big-endian words, and a bit length */ function core_sha1(x, len) { /* append padding */ x[len >> 5] |= 0x80 << (24 - len % 32); x[((len + 64 >> 9) << 4) + 15] = len; var w = Array(80); var a = 1732584193; var b = -271733879; var c = -1732584194; var d = 271733878; var e = -1009589776; for (var i = 0; i < x.length; i += 16) { var olda = a; var oldb = b; var oldc = c; var oldd = d; var olde = e; for (var j = 0; j < 80; j++) { if (j < 16) { w[j] = x[i + j]; } else { w[j] = rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1); } var t = safe_add( safe_add(rol(a, 5), sha1_ft(j, b, c, d)), safe_add(safe_add(e, w[j]), sha1_kt(j)) ); e = d; d = c; c = rol(b, 30); b = a; a = t; } a = safe_add(a, olda); b = safe_add(b, oldb); c = safe_add(c, oldc); d = safe_add(d, oldd); e = safe_add(e, olde); } return Array(a, b, c, d, e); } /* * Perform the appropriate triplet combination function for the current * iteration */ function sha1_ft(t, b, c, d) { if (t < 20) { return (b & c) | (~b & d); } if (t < 40) { return b ^ c ^ d; } if (t < 60) { return (b & c) | (b & d) | (c & d); } return b ^ c ^ d; } /* * Determine the appropriate additive constant for the current iteration */ function sha1_kt(t) { return t < 20 ? 1518500249 : t < 40 ? 1859775393 : t < 60 ? -1894007588 : -899497514; } /* * Calculate the HMAC-SHA1 of a key and some data */ function core_hmac_sha1(key, data) { var bkey = str2binb(key); if (bkey.length > 16) { bkey = core_sha1(bkey, key.length * chrsz); } var ipad = Array(16), opad = Array(16); for (var i = 0; i < 16; i++) { ipad[i] = bkey[i] ^ 0x36363636; opad[i] = bkey[i] ^ 0x5C5C5C5C; } var hash = core_sha1(ipad.concat(str2binb(data)), 512 + data.length * chrsz); return core_sha1(opad.concat(hash), 512 + 160); } /* * Add integers, wrapping at 2^32. This uses 16-bit operations internally * to work around bugs in some JS interpreters. */ function safe_add(x, y) { var lsw = (x & 0xFFFF) + (y & 0xFFFF); var msw = (x >> 16) + (y >> 16) + (lsw >> 16); return (msw << 16) | (lsw & 0xFFFF); } /* * Bitwise rotate a 32-bit number to the left. */ function rol(num, cnt) { return (num << cnt) | (num >>> (32 - cnt)); } /* * Convert an 8-bit or 16-bit string to an array of big-endian words * In 8-bit function, characters >255 have their hi-byte silently ignored. */ function str2binb(str) { var bin = Array(); var mask = (1 << chrsz) - 1; for (var i = 0; i < str.length * chrsz; i += chrsz) { bin[i >> 5] |= (str.charCodeAt(i / chrsz) & mask) << (32 - chrsz - i % 32); } return bin; } /* * Convert an array of big-endian words to a string */ function binb2str(bin) { var str = ''; var mask = (1 << chrsz) - 1; for (var i = 0; i < bin.length * 32; i += chrsz) { str += String.fromCharCode((bin[i >> 5] >>> (32 - chrsz - i % 32)) & mask); } return str; } /* * Convert an array of big-endian words to a hex string. */ function binb2hex(binarray) { var hex_tab = hexcase ? '0123456789ABCDEF' : '0123456789abcdef'; var str = ''; for (var i = 0; i < binarray.length * 4; i++) { str += hex_tab.charAt((binarray[i >> 2] >> ((3 - i % 4) * 8 + 4)) & 0xF) + hex_tab.charAt((binarray[i >> 2] >> ((3 - i % 4) * 8)) & 0xF); } return str; } /* * Convert an array of big-endian words to a base-64 string */ function binb2b64(binarray) { var tab = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; var str = ''; for (var i = 0; i < binarray.length * 4; i += 3) { var triplet = (((binarray[i >> 2] >> 8 * (3 - i % 4)) & 0xFF) << 16) | (((binarray[i + 1 >> 2] >> 8 * (3 - (i + 1) % 4)) & 0xFF) << 8) | ((binarray[i + 2 >> 2] >> 8 * (3 - (i + 2) % 4)) & 0xFF); for (var j = 0; j < 4; j++) { if (i * 8 + j * 6 > binarray.length * 32) { str += b64pad; } else { str += tab.charAt((triplet >> 6 * (3 - j)) & 0x3F); } } } return str; } }); require.define('/test.js', function (require, module, exports, __dirname, __filename) { var crypto = require('crypto'); var abc = crypto.createHash('sha1').update('abc').digest('hex'); console.log(abc); // require('hello').inlineCall().call2() }); require('/test.js'); browserify-crypto-browserify-ab8920b/example/index.html 0000664 0000000 0000000 00000000472 14705755022 0023467 0 ustar 00root root 0000000 0000000
require('crypto').createHash('sha1').update('abc').digest('hex') == ''
browserify-crypto-browserify-ab8920b/example/test.js 0000664 0000000 0000000 00000000253 14705755022 0023004 0 ustar 00root root 0000000 0000000 'use strict';
var crypto = require('crypto');
var abc = crypto.createHash('sha1').update('abc').digest('hex');
console.log(abc);
// require('hello').inlineCall().call2()
browserify-crypto-browserify-ab8920b/index.js 0000664 0000000 0000000 00000005653 14705755022 0021512 0 ustar 00root root 0000000 0000000 'use strict';
// eslint-disable-next-line no-multi-assign
exports.randomBytes = exports.rng = exports.pseudoRandomBytes = exports.prng = require('randombytes');
// eslint-disable-next-line no-multi-assign
exports.createHash = exports.Hash = require('create-hash');
// eslint-disable-next-line no-multi-assign
exports.createHmac = exports.Hmac = require('create-hmac');
var algos = require('browserify-sign/algos');
var algoKeys = Object.keys(algos);
var hashes = [
'sha1',
'sha224',
'sha256',
'sha384',
'sha512',
'md5',
'rmd160'
].concat(algoKeys);
exports.getHashes = function () {
return hashes;
};
var p = require('pbkdf2');
exports.pbkdf2 = p.pbkdf2;
exports.pbkdf2Sync = p.pbkdf2Sync;
var aes = require('browserify-cipher');
exports.Cipher = aes.Cipher;
exports.createCipher = aes.createCipher;
exports.Cipheriv = aes.Cipheriv;
exports.createCipheriv = aes.createCipheriv;
exports.Decipher = aes.Decipher;
exports.createDecipher = aes.createDecipher;
exports.Decipheriv = aes.Decipheriv;
exports.createDecipheriv = aes.createDecipheriv;
exports.getCiphers = aes.getCiphers;
exports.listCiphers = aes.listCiphers;
var dh = require('diffie-hellman');
exports.DiffieHellmanGroup = dh.DiffieHellmanGroup;
exports.createDiffieHellmanGroup = dh.createDiffieHellmanGroup;
exports.getDiffieHellman = dh.getDiffieHellman;
exports.createDiffieHellman = dh.createDiffieHellman;
exports.DiffieHellman = dh.DiffieHellman;
var sign = require('browserify-sign');
exports.createSign = sign.createSign;
exports.Sign = sign.Sign;
exports.createVerify = sign.createVerify;
exports.Verify = sign.Verify;
exports.createECDH = require('create-ecdh');
var publicEncrypt = require('public-encrypt');
exports.publicEncrypt = publicEncrypt.publicEncrypt;
exports.privateEncrypt = publicEncrypt.privateEncrypt;
exports.publicDecrypt = publicEncrypt.publicDecrypt;
exports.privateDecrypt = publicEncrypt.privateDecrypt;
// the least I can do is make error messages for the rest of the node.js/crypto api.
// [
// 'createCredentials'
// ].forEach(function (name) {
// exports[name] = function () {
// throw new Error('sorry, ' + name + ' is not implemented yet\nwe accept pull requests\nhttps://github.com/browserify/crypto-browserify');
// };
// });
var rf = require('randomfill');
exports.randomFill = rf.randomFill;
exports.randomFillSync = rf.randomFillSync;
exports.createCredentials = function () {
throw new Error('sorry, createCredentials is not implemented yet\nwe accept pull requests\nhttps://github.com/browserify/crypto-browserify');
};
exports.constants = {
DH_CHECK_P_NOT_SAFE_PRIME: 2,
DH_CHECK_P_NOT_PRIME: 1,
DH_UNABLE_TO_CHECK_GENERATOR: 4,
DH_NOT_SUITABLE_GENERATOR: 8,
NPN_ENABLED: 1,
ALPN_ENABLED: 1,
RSA_PKCS1_PADDING: 1,
RSA_SSLV23_PADDING: 2,
RSA_NO_PADDING: 3,
RSA_PKCS1_OAEP_PADDING: 4,
RSA_X931_PADDING: 5,
RSA_PKCS1_PSS_PADDING: 6,
POINT_CONVERSION_COMPRESSED: 2,
POINT_CONVERSION_UNCOMPRESSED: 4,
POINT_CONVERSION_HYBRID: 6
};
browserify-crypto-browserify-ab8920b/package.json 0000664 0000000 0000000 00000002516 14705755022 0022326 0 ustar 00root root 0000000 0000000 {
"author": "Dominic Tarr