You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bo...@apache.org on 2014/10/14 19:11:26 UTC

android commit: Replacing Math.random() with something a little more random.

Repository: cordova-android
Updated Branches:
  refs/heads/master 9f4190689 -> b37498d5f


Replacing Math.random() with something a little more random.


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/b37498d5
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/b37498d5
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/b37498d5

Branch: refs/heads/master
Commit: b37498d5f61faf37c5cbe7ca58f004ceacdffb0f
Parents: 9f41906
Author: Joe Bowser <bo...@apache.org>
Authored: Tue Oct 14 10:11:09 2014 -0700
Committer: Joe Bowser <bo...@apache.org>
Committed: Tue Oct 14 10:11:09 2014 -0700

----------------------------------------------------------------------
 framework/src/org/apache/cordova/CordovaBridge.java | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/b37498d5/framework/src/org/apache/cordova/CordovaBridge.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaBridge.java b/framework/src/org/apache/cordova/CordovaBridge.java
index 081127d..a6ebebb 100644
--- a/framework/src/org/apache/cordova/CordovaBridge.java
+++ b/framework/src/org/apache/cordova/CordovaBridge.java
@@ -18,6 +18,8 @@
 */
 package org.apache.cordova;
 
+import java.security.SecureRandom;
+
 import org.apache.cordova.PluginManager;
 import org.json.JSONArray;
 import org.json.JSONException;
@@ -107,7 +109,8 @@ public class CordovaBridge {
 
     /** Called by cordova.js to initialize the bridge. */
     int generateBridgeSecret() {
-        expectedBridgeSecret = (int)(Math.random() * Integer.MAX_VALUE);
+        SecureRandom randGen = new SecureRandom();
+        expectedBridgeSecret = (int)(randGen.nextInt() * Integer.MAX_VALUE);
         return expectedBridgeSecret;
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org