Security Principiante

Obtiene la implementación más fuerte de SecureRandom de la plataforma.

✕ Java 8
// Default algorithm — may not be
// the strongest available
SecureRandom random =
    new SecureRandom();
byte[] bytes = new byte[32];
random.nextBytes(bytes);
✓ Java 9+
// Platform's strongest algorithm
SecureRandom random =
    SecureRandom.getInstanceStrong();
byte[] bytes = new byte[32];
random.nextBytes(bytes);
¿Ves un problema con este código? Cuéntanos.
🛡️

La más fuerte disponible

Selecciona automáticamente el mejor algoritmo para la plataforma.

📖

Intención explícita

Comunica claramente que se requiere aleatoriedad fuerte.

🔧

Configurable

Los administradores pueden cambiar el algoritmo fuerte mediante propiedades de seguridad.

Enfoque Antiguo
new SecureRandom()
Enfoque Moderno
getInstanceStrong()
Desde JDK
9
Dificultad
Principiante
Generación de aleatorios fuertes
Disponible

Ampliamente disponible desde JDK 9 (sept. 2017)

getInstanceStrong() devuelve la implementación de SecureRandom configurada como la más fuerte en la plataforma. Esto se controla mediante la propiedad de seguridad securerandom.strongAlgorithms.

Compartir 𝕏 🦋 in