Security Początkujący

Get the platform's strongest SecureRandom implementation.

✕ 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);
Widzisz problem z tym kodem? Daj nam znać.
🛡️

Strongest available

Automatically selects the best algorithm for the platform.

📖

Explicit intent

Clearly communicates that strong randomness is required.

🔧

Configurable

Administrators can change the strong algorithm via security properties.

Stare podejście
new SecureRandom()
Nowoczesne podejście
getInstanceStrong()
Od JDK
9
Poziom trudności
Początkujący
Strong random generation
Dostępne

Widely available since JDK 9 (Sept 2017)

getInstanceStrong() returns the SecureRandom implementation configured as the strongest on the platform. This is controlled by the securerandom.strongAlgorithms security property.

Udostępnij 𝕏 🦋 in