IT WORKS!

This commit is contained in:
Arik Sosman 2016-01-12 18:29:05 -08:00
parent 87acf6fe1c
commit 31c3704264
2 changed files with 14 additions and 6 deletions

View File

@ -8,7 +8,7 @@ var sjclRandom = new sjcl.prng(10);
var explicitReq = require;
var RNRandomBytes = explicitReq('react-native').NativeModules.RNRandomBytes;
module.exports.randomBytes = function(length, cb) {
var randomBytes = function(length, cb) {
if (!cb) {
var size = length;
@ -30,7 +30,15 @@ module.exports.randomBytes = function(length, cb) {
};
module.exports.randomBytes(4096, function(err, buffer) {
var seedStanford = function(){
randomBytes(4096, function(err, buffer){
var hexString = buffer.toString('hex');
sjclRandom.addEntropy(hexString, 10, 'csprng');
var stanfordSeed = sjcl.codec.hex.toBits(hexString);
sjclRandom.addEntropy(stanfordSeed);
});
};
module.exports = {
randomBytes: randomBytes,
seedStanford: seedStanford
};

View File

@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"babelify": "mkdir -p browser && ./node_modules/.bin/browserify --exclude react-native -t [ babelify --presets [ react es2015 ] ] ./index.js | sed -e 's/require/bitgoReq/g' | sed -e 's/explicitReq(/require(/g' > ./browser/react_index.js"
"babelify": "mkdir -p browser && ./node_modules/.bin/browserify --exclude react-native -t [ babelify --presets [ react es2015 ] ] -s BitGoRandomBytes ./index.js | sed -e 's/require/bitgoReq/g' | sed -e 's/explicitReq(/require(/g' > ./browser/react_index.js"
},
"keywords": [
"react-component",