react / react-0.13.3 / examples / basic-commonjs / node_modules / browserify / node_modules / crypto-browserify / example / bundle.js
80728 viewsvar require = function (file, cwd) {1var resolved = require.resolve(file, cwd || '/');2var mod = require.modules[resolved];3if (!mod) throw new Error(4'Failed to resolve module ' + file + ', tried ' + resolved5);6var res = mod._cached ? mod._cached : mod();7return res;8}910require.paths = [];11require.modules = {};12require.extensions = [".js",".coffee"];1314require._core = {15'assert': true,16'events': true,17'fs': true,18'path': true,19'vm': true20};2122require.resolve = (function () {23return function (x, cwd) {24if (!cwd) cwd = '/';2526if (require._core[x]) return x;27var path = require.modules.path();28cwd = path.resolve('/', cwd);29var y = cwd || '/';3031if (x.match(/^(?:\.\.?\/|\/)/)) {32var m = loadAsFileSync(path.resolve(y, x))33|| loadAsDirectorySync(path.resolve(y, x));34if (m) return m;35}3637var n = loadNodeModulesSync(x, y);38if (n) return n;3940throw new Error("Cannot find module '" + x + "'");4142function loadAsFileSync (x) {43if (require.modules[x]) {44return x;45}4647for (var i = 0; i < require.extensions.length; i++) {48var ext = require.extensions[i];49if (require.modules[x + ext]) return x + ext;50}51}5253function loadAsDirectorySync (x) {54x = x.replace(/\/+$/, '');55var pkgfile = x + '/package.json';56if (require.modules[pkgfile]) {57var pkg = require.modules[pkgfile]();58var b = pkg.browserify;59if (typeof b === 'object' && b.main) {60var m = loadAsFileSync(path.resolve(x, b.main));61if (m) return m;62}63else if (typeof b === 'string') {64var m = loadAsFileSync(path.resolve(x, b));65if (m) return m;66}67else if (pkg.main) {68var m = loadAsFileSync(path.resolve(x, pkg.main));69if (m) return m;70}71}7273return loadAsFileSync(x + '/index');74}7576function loadNodeModulesSync (x, start) {77var dirs = nodeModulesPathsSync(start);78for (var i = 0; i < dirs.length; i++) {79var dir = dirs[i];80var m = loadAsFileSync(dir + '/' + x);81if (m) return m;82var n = loadAsDirectorySync(dir + '/' + x);83if (n) return n;84}8586var m = loadAsFileSync(x);87if (m) return m;88}8990function nodeModulesPathsSync (start) {91var parts;92if (start === '/') parts = [ '' ];93else parts = path.normalize(start).split('/');9495var dirs = [];96for (var i = parts.length - 1; i >= 0; i--) {97if (parts[i] === 'node_modules') continue;98var dir = parts.slice(0, i + 1).join('/') + '/node_modules';99dirs.push(dir);100}101102return dirs;103}104};105})();106107require.alias = function (from, to) {108var path = require.modules.path();109var res = null;110try {111res = require.resolve(from + '/package.json', '/');112}113catch (err) {114res = require.resolve(from, '/');115}116var basedir = path.dirname(res);117118var keys = (Object.keys || function (obj) {119var res = [];120for (var key in obj) res.push(key)121return res;122})(require.modules);123124for (var i = 0; i < keys.length; i++) {125var key = keys[i];126if (key.slice(0, basedir.length + 1) === basedir + '/') {127var f = key.slice(basedir.length);128require.modules[to + f] = require.modules[basedir + f];129}130else if (key === basedir) {131require.modules[to] = require.modules[basedir];132}133}134};135136require.define = function (filename, fn) {137var dirname = require._core[filename]138? ''139: require.modules.path().dirname(filename)140;141142var require_ = function (file) {143return require(file, dirname)144};145require_.resolve = function (name) {146return require.resolve(name, dirname);147};148require_.modules = require.modules;149require_.define = require.define;150var module_ = { exports : {} };151152require.modules[filename] = function () {153require.modules[filename]._cached = module_.exports;154fn.call(155module_.exports,156require_,157module_,158module_.exports,159dirname,160filename161);162require.modules[filename]._cached = module_.exports;163return module_.exports;164};165};166167if (typeof process === 'undefined') process = {};168169if (!process.nextTick) process.nextTick = (function () {170var queue = [];171var canPost = typeof window !== 'undefined'172&& window.postMessage && window.addEventListener173;174175if (canPost) {176window.addEventListener('message', function (ev) {177if (ev.source === window && ev.data === 'browserify-tick') {178ev.stopPropagation();179if (queue.length > 0) {180var fn = queue.shift();181fn();182}183}184}, true);185}186187return function (fn) {188if (canPost) {189queue.push(fn);190window.postMessage('browserify-tick', '*');191}192else setTimeout(fn, 0);193};194})();195196if (!process.title) process.title = 'browser';197198if (!process.binding) process.binding = function (name) {199if (name === 'evals') return require('vm')200else throw new Error('No such module')201};202203if (!process.cwd) process.cwd = function () { return '.' };204205if (!process.env) process.env = {};206if (!process.argv) process.argv = [];207208require.define("path", function (require, module, exports, __dirname, __filename) {209function filter (xs, fn) {210var res = [];211for (var i = 0; i < xs.length; i++) {212if (fn(xs[i], i, xs)) res.push(xs[i]);213}214return res;215}216217// resolves . and .. elements in a path array with directory names there218// must be no slashes, empty elements, or device names (c:\) in the array219// (so also no leading and trailing slashes - it does not distinguish220// relative and absolute paths)221function normalizeArray(parts, allowAboveRoot) {222// if the path tries to go above the root, `up` ends up > 0223var up = 0;224for (var i = parts.length; i >= 0; i--) {225var last = parts[i];226if (last == '.') {227parts.splice(i, 1);228} else if (last === '..') {229parts.splice(i, 1);230up++;231} else if (up) {232parts.splice(i, 1);233up--;234}235}236237// if the path is allowed to go above the root, restore leading ..s238if (allowAboveRoot) {239for (; up--; up) {240parts.unshift('..');241}242}243244return parts;245}246247// Regex to split a filename into [*, dir, basename, ext]248// posix version249var splitPathRe = /^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;250251// path.resolve([from ...], to)252// posix version253exports.resolve = function() {254var resolvedPath = '',255resolvedAbsolute = false;256257for (var i = arguments.length; i >= -1 && !resolvedAbsolute; i--) {258var path = (i >= 0)259? arguments[i]260: process.cwd();261262// Skip empty and invalid entries263if (typeof path !== 'string' || !path) {264continue;265}266267resolvedPath = path + '/' + resolvedPath;268resolvedAbsolute = path.charAt(0) === '/';269}270271// At this point the path should be resolved to a full absolute path, but272// handle relative paths to be safe (might happen when process.cwd() fails)273274// Normalize the path275resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {276return !!p;277}), !resolvedAbsolute).join('/');278279return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';280};281282// path.normalize(path)283// posix version284exports.normalize = function(path) {285var isAbsolute = path.charAt(0) === '/',286trailingSlash = path.slice(-1) === '/';287288// Normalize the path289path = normalizeArray(filter(path.split('/'), function(p) {290return !!p;291}), !isAbsolute).join('/');292293if (!path && !isAbsolute) {294path = '.';295}296if (path && trailingSlash) {297path += '/';298}299300return (isAbsolute ? '/' : '') + path;301};302303304// posix version305exports.join = function() {306var paths = Array.prototype.slice.call(arguments, 0);307return exports.normalize(filter(paths, function(p, index) {308return p && typeof p === 'string';309}).join('/'));310};311312313exports.dirname = function(path) {314var dir = splitPathRe.exec(path)[1] || '';315var isWindows = false;316if (!dir) {317// No dirname318return '.';319} else if (dir.length === 1 ||320(isWindows && dir.length <= 3 && dir.charAt(1) === ':')) {321// It is just a slash or a drive letter with a slash322return dir;323} else {324// It is a full dirname, strip trailing slash325return dir.substring(0, dir.length - 1);326}327};328329330exports.basename = function(path, ext) {331var f = splitPathRe.exec(path)[2] || '';332// TODO: make this comparison case-insensitive on windows?333if (ext && f.substr(-1 * ext.length) === ext) {334f = f.substr(0, f.length - ext.length);335}336return f;337};338339340exports.extname = function(path) {341return splitPathRe.exec(path)[3] || '';342};343344});345346require.define("crypto", function (require, module, exports, __dirname, __filename) {347module.exports = require("crypto-browserify")348});349350require.define("/node_modules/crypto-browserify/package.json", function (require, module, exports, __dirname, __filename) {351module.exports = {}352});353354require.define("/node_modules/crypto-browserify/index.js", function (require, module, exports, __dirname, __filename) {355var sha = require('./sha')356357var algorithms = {358sha1: {359hex: sha.hex_sha1,360binary: sha.b64_sha1,361ascii: sha.str_sha1362}363}364365function error () {366var m = [].slice.call(arguments).join(' ')367throw new Error([368m,369'we accept pull requests',370'http://github.com/dominictarr/crypto-browserify'371].join('\n'))372}373374exports.createHash = function (alg) {375alg = alg || 'sha1'376if(!algorithms[alg])377error('algorithm:', alg, 'is not yet supported')378var s = ''379_alg = algorithms[alg]380return {381update: function (data) {382s += data383return this384},385digest: function (enc) {386enc = enc || 'binary'387var fn388if(!(fn = _alg[enc]))389error('encoding:', enc , 'is not yet supported for algorithm', alg)390var r = fn(s)391s = null //not meant to use the hash after you've called digest.392return r393}394}395}396// the least I can do is make error messages for the rest of the node.js/crypto api.397;['createCredentials'398, 'createHmac'399, 'createCypher'400, 'createCypheriv'401, 'createDecipher'402, 'createDecipheriv'403, 'createSign'404, 'createVerify'405, 'createDeffieHellman',406, 'pbkdf2',407, 'randomBytes' ].forEach(function (name) {408exports[name] = function () {409error('sorry,', name, 'is not implemented yet')410}411})412413});414415require.define("/node_modules/crypto-browserify/sha.js", function (require, module, exports, __dirname, __filename) {416/*417* A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined418* in FIPS PUB 180-1419* Version 2.1a Copyright Paul Johnston 2000 - 2002.420* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet421* Distributed under the BSD License422* See http://pajhome.org.uk/crypt/md5 for details.423*/424425exports.hex_sha1 = hex_sha1;426exports.b64_sha1 = b64_sha1;427exports.str_sha1 = str_sha1;428exports.hex_hmac_sha1 = hex_hmac_sha1;429exports.b64_hmac_sha1 = b64_hmac_sha1;430exports.str_hmac_sha1 = str_hmac_sha1;431432/*433* Configurable variables. You may need to tweak these to be compatible with434* the server-side, but the defaults work in most cases.435*/436var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */437var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */438var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */439440/*441* These are the functions you'll usually want to call442* They take string arguments and return either hex or base-64 encoded strings443*/444function hex_sha1(s){return binb2hex(core_sha1(str2binb(s),s.length * chrsz));}445function b64_sha1(s){return binb2b64(core_sha1(str2binb(s),s.length * chrsz));}446function str_sha1(s){return binb2str(core_sha1(str2binb(s),s.length * chrsz));}447function hex_hmac_sha1(key, data){ return binb2hex(core_hmac_sha1(key, data));}448function b64_hmac_sha1(key, data){ return binb2b64(core_hmac_sha1(key, data));}449function str_hmac_sha1(key, data){ return binb2str(core_hmac_sha1(key, data));}450451/*452* Perform a simple self-test to see if the VM is working453*/454function sha1_vm_test()455{456return hex_sha1("abc") == "a9993e364706816aba3e25717850c26c9cd0d89d";457}458459/*460* Calculate the SHA-1 of an array of big-endian words, and a bit length461*/462function core_sha1(x, len)463{464/* append padding */465x[len >> 5] |= 0x80 << (24 - len % 32);466x[((len + 64 >> 9) << 4) + 15] = len;467468var w = Array(80);469var a = 1732584193;470var b = -271733879;471var c = -1732584194;472var d = 271733878;473var e = -1009589776;474475for(var i = 0; i < x.length; i += 16)476{477var olda = a;478var oldb = b;479var oldc = c;480var oldd = d;481var olde = e;482483for(var j = 0; j < 80; j++)484{485if(j < 16) w[j] = x[i + j];486else w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1);487var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)),488safe_add(safe_add(e, w[j]), sha1_kt(j)));489e = d;490d = c;491c = rol(b, 30);492b = a;493a = t;494}495496a = safe_add(a, olda);497b = safe_add(b, oldb);498c = safe_add(c, oldc);499d = safe_add(d, oldd);500e = safe_add(e, olde);501}502return Array(a, b, c, d, e);503504}505506/*507* Perform the appropriate triplet combination function for the current508* iteration509*/510function sha1_ft(t, b, c, d)511{512if(t < 20) return (b & c) | ((~b) & d);513if(t < 40) return b ^ c ^ d;514if(t < 60) return (b & c) | (b & d) | (c & d);515return b ^ c ^ d;516}517518/*519* Determine the appropriate additive constant for the current iteration520*/521function sha1_kt(t)522{523return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 :524(t < 60) ? -1894007588 : -899497514;525}526527/*528* Calculate the HMAC-SHA1 of a key and some data529*/530function core_hmac_sha1(key, data)531{532var bkey = str2binb(key);533if(bkey.length > 16) bkey = core_sha1(bkey, key.length * chrsz);534535var ipad = Array(16), opad = Array(16);536for(var i = 0; i < 16; i++)537{538ipad[i] = bkey[i] ^ 0x36363636;539opad[i] = bkey[i] ^ 0x5C5C5C5C;540}541542var hash = core_sha1(ipad.concat(str2binb(data)), 512 + data.length * chrsz);543return core_sha1(opad.concat(hash), 512 + 160);544}545546/*547* Add integers, wrapping at 2^32. This uses 16-bit operations internally548* to work around bugs in some JS interpreters.549*/550function safe_add(x, y)551{552var lsw = (x & 0xFFFF) + (y & 0xFFFF);553var msw = (x >> 16) + (y >> 16) + (lsw >> 16);554return (msw << 16) | (lsw & 0xFFFF);555}556557/*558* Bitwise rotate a 32-bit number to the left.559*/560function rol(num, cnt)561{562return (num << cnt) | (num >>> (32 - cnt));563}564565/*566* Convert an 8-bit or 16-bit string to an array of big-endian words567* In 8-bit function, characters >255 have their hi-byte silently ignored.568*/569function str2binb(str)570{571var bin = Array();572var mask = (1 << chrsz) - 1;573for(var i = 0; i < str.length * chrsz; i += chrsz)574bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (32 - chrsz - i%32);575return bin;576}577578/*579* Convert an array of big-endian words to a string580*/581function binb2str(bin)582{583var str = "";584var mask = (1 << chrsz) - 1;585for(var i = 0; i < bin.length * 32; i += chrsz)586str += String.fromCharCode((bin[i>>5] >>> (32 - chrsz - i%32)) & mask);587return str;588}589590/*591* Convert an array of big-endian words to a hex string.592*/593function binb2hex(binarray)594{595var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";596var str = "";597for(var i = 0; i < binarray.length * 4; i++)598{599str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) +600hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8 )) & 0xF);601}602return str;603}604605/*606* Convert an array of big-endian words to a base-64 string607*/608function binb2b64(binarray)609{610var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";611var str = "";612for(var i = 0; i < binarray.length * 4; i += 3)613{614var triplet = (((binarray[i >> 2] >> 8 * (3 - i %4)) & 0xFF) << 16)615| (((binarray[i+1 >> 2] >> 8 * (3 - (i+1)%4)) & 0xFF) << 8 )616| ((binarray[i+2 >> 2] >> 8 * (3 - (i+2)%4)) & 0xFF);617for(var j = 0; j < 4; j++)618{619if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;620else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);621}622}623return str;624}625626627});628629require.define("/test.js", function (require, module, exports, __dirname, __filename) {630var crypto = require('crypto')631var abc = crypto.createHash('sha1').update('abc').digest('hex')632console.log(abc)633//require('hello').inlineCall().call2()634635});636require("/test.js");637638639