Skip to content
Snippets Groups Projects
Commit 570e8bbe authored by ylecollen's avatar ylecollen
Browse files

use secureRandom in getRandomKey

parent ce9f67d5
No related branches found
No related tags found
No related merge requests found
...@@ -20,7 +20,7 @@ package org.matrix.olm; ...@@ -20,7 +20,7 @@ package org.matrix.olm;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import java.util.Random; import java.security.SecureRandom;
/** /**
* Olm SDK helper class. * Olm SDK helper class.
...@@ -138,16 +138,10 @@ public class OlmUtility { ...@@ -138,16 +138,10 @@ public class OlmUtility {
* @return string containing randoms integer values * @return string containing randoms integer values
*/ */
public static String getRandomKey() { public static String getRandomKey() {
String keyRetValue; SecureRandom secureRandom = new SecureRandom();
Random rand = new Random(); byte[] buffer = new byte[RANDOM_KEY_SIZE];
StringBuilder strBuilder = new StringBuilder(); secureRandom.nextBytes(buffer);
return new String(buffer);
for(int i = 0; i< RANDOM_KEY_SIZE; i++) {
strBuilder.append(rand.nextInt(RANDOM_RANGE));
}
keyRetValue = strBuilder.toString();
return keyRetValue;
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment