mirror of
https://github.com/status-im/bip39.git
synced 2025-01-09 12:15:45 +00:00
index: default to randomBuffer
This commit is contained in:
parent
e569aeb6d7
commit
99981a1de6
4
index.js
4
index.js
@ -35,9 +35,9 @@ BIP39.prototype.entropyToMnemonic = function(entropy) {
|
|||||||
|
|
||||||
BIP39.prototype.generateMnemonic = function(strength, rng) {
|
BIP39.prototype.generateMnemonic = function(strength, rng) {
|
||||||
strength = strength || 128
|
strength = strength || 128
|
||||||
rng = rng || secureRandom
|
rng = rng || secureRandom.randomBuffer
|
||||||
|
|
||||||
var hex = rng.randomBuffer(strength / 8).toString('hex')
|
var hex = rng(strength / 8).toString('hex')
|
||||||
return this.entropyToMnemonic(hex)
|
return this.entropyToMnemonic(hex)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,12 +36,10 @@ describe('generateMnemonic', function() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('allows a custom RNG to be used', function() {
|
it('allows a custom RNG to be used', function() {
|
||||||
var rng = {
|
var rng = function(size) {
|
||||||
randomBuffer: function(size) {
|
var buffer = new Buffer(size)
|
||||||
var buffer = new Buffer(size)
|
buffer.fill(4) // guaranteed random
|
||||||
buffer.fill(4) // guaranteed random
|
return buffer
|
||||||
return buffer
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var mnemonic = bip39.generateMnemonic(64, rng)
|
var mnemonic = bip39.generateMnemonic(64, rng)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user