sjcl.random.addEntropy():

Fixed bug: Now accepts Uint32Array for data
This commit is contained in:
unknown 2012-07-24 15:08:25 -05:00
parent 8bf8bbbf3c
commit 0278f2f177
1 changed files with 14 additions and 5 deletions

View File

@ -100,13 +100,22 @@ sjcl.random = {
break; break;
case "object": case "object":
if (Object.prototype.toString.call(data) !== "[object Array]") { var objName = Object.prototype.toString.call(data);
err = 1; if (objName === "[object Uint32Array]") {
} tmp = [];
for (i=0; i<data.length && !err; i++) { for (i = 0; i < data.length; i++) {
if (typeof(data[i]) != "number") { tmp.push(data[i]);
}
data = tmp;
} else {
if (objName !== "[object Array]") {
err = 1; err = 1;
} }
for (i=0; i<data.length && !err; i++) {
if (typeof(data[i]) != "number") {
err = 1;
}
}
} }
if (!err) { if (!err) {
if (estimatedEntropy === undefined) { if (estimatedEntropy === undefined) {