diff --git a/model/api/src/main/java/org/keycloak/models/utils/HmacOTP.java b/model/api/src/main/java/org/keycloak/models/utils/HmacOTP.java index 210f82b453..1f42f571ff 100755 --- a/model/api/src/main/java/org/keycloak/models/utils/HmacOTP.java +++ b/model/api/src/main/java/org/keycloak/models/utils/HmacOTP.java @@ -3,7 +3,7 @@ package org.keycloak.models.utils; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; import java.math.BigInteger; -import java.util.Random; +import java.security.SecureRandom; /** * @author Bill Burke @@ -29,7 +29,7 @@ public class HmacOTP { public static String generateSecret(int length) { String chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW1234567890"; - Random r = new Random(); + SecureRandom r = new SecureRandom(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < length; i++) { char c = chars.charAt(r.nextInt(chars.length()));