فهرست منبع

randomness in Chrome

Mike Hamburg 15 سال پیش
والد
کامیت
c1fcb9a560
1فایلهای تغییر یافته به همراه10 افزوده شده و 0 حذف شده
  1. 10 0
      core/random.js

+ 10 - 0
core/random.js

@@ -366,3 +366,13 @@ sjcl.random = {
   }
 };
 
+(function(){
+  try {
+    // get cryptographically strong entropy in Webkit
+    var ab = new Uint32Array(32), i;
+    crypto.getRandomValues(ab);
+    sjcl.random.addEntropy(ab, 1024, "crypto.getRandomValues");
+  } catch (e) {
+    // no getRandomValues :-(
+  }
+})();