Beta 7 with some repo names changed.

This commit is contained in:
Luis Fernando Molina committed 2020-11-15 13:05:19 +01:00
1 parent 0f7b40cca7
commit 963c19493a
3408 files changed
+462217 -15516

No files matched your search

+65
View File
@@ -0,0 +1,65 @@
var r;
module.exports = function rand(len) {
if (!r)
r = new Rand(null);
return r.generate(len);
};
function Rand(rand) {
this.rand = rand;
}
module.exports.Rand = Rand;
Rand.prototype.generate = function generate(len) {
return this._rand(len);
};
// Emulate crypto API using randy
Rand.prototype._rand = function _rand(n) {
if (this.rand.getBytes)
return this.rand.getBytes(n);
var res = new Uint8Array(n);
for (var i = 0; i < res.length; i++)
res[i] = this.rand.getByte();
return res;
};
if (typeof self === 'object') {
if (self.crypto && self.crypto.getRandomValues) {
// Modern browsers
Rand.prototype._rand = function _rand(n) {
var arr = new Uint8Array(n);
self.crypto.getRandomValues(arr);
return arr;
};
} else if (self.msCrypto && self.msCrypto.getRandomValues) {
// IE
Rand.prototype._rand = function _rand(n) {
var arr = new Uint8Array(n);
self.msCrypto.getRandomValues(arr);
return arr;
};
// Safari's WebWorkers do not have `crypto`
} else if (typeof window === 'object') {
// Old junk
Rand.prototype._rand = function() {
throw new Error('Not implemented yet');
};
}
} else {
// Node.js or Web worker with no crypto support
try {
var crypto = require('crypto');
if (typeof crypto.randomBytes !== 'function')
throw new Error('Not supported');
Rand.prototype._rand = function _rand(n) {
return crypto.randomBytes(n);
};
} catch (e) {
}
}
+60
View File
@@ -0,0 +1,60 @@
{
"_from": "brorand@^1.0.1",
"_id": "brorand@1.1.0",
"_inBundle": false,
"_integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=",
"_location": "/brorand",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "brorand@^1.0.1",
"name": "brorand",
"escapedName": "brorand",
"rawSpec": "^1.0.1",
"saveSpec": null,
"fetchSpec": "^1.0.1"
},
"_requiredBy": [
"/elliptic",
"/miller-rabin"
],
"_resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz",
"_shasum": "12c25efe40a45e3c323eb8675a0a0ce57b22371f",
"_spec": "brorand@^1.0.1",
"_where": "C:\\Users\\Luis\\source\\repos\\AAMasters\\BackendServers\\node_modules\\elliptic",
"author": {
"name": "Fedor Indutny",
"email": "fedor@indutny.com"
},
"browser": {
"crypto": false
},
"bugs": {
"url": "https://github.com/indutny/brorand/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Random number generator for browsers and node.js",
"devDependencies": {
"mocha": "^2.0.1"
},
"homepage": "https://github.com/indutny/brorand",
"keywords": [
"Random",
"RNG",
"browser",
"crypto"
],
"license": "MIT",
"main": "index.js",
"name": "brorand",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/indutny/brorand.git"
},
"scripts": {
"test": "mocha --reporter=spec test/**/*-test.js"
},
"version": "1.1.0"
}
+8
View File
@@ -0,0 +1,8 @@
var brorand = require('../');
var assert = require('assert');
describe('Brorand', function() {
it('should generate random numbers', function() {
assert.equal(brorand(100).length, 100);
});
});