secure Random Bytes
Generates cryptographically secure random bytes.
Uses platform-specific CSPRNG:
JVM: java.security.SecureRandom
JS: crypto.getRandomValues
Native: libsodium randombytes_buf
Return
ByteArray of cryptographically secure random bytes
Parameters
Number of random bytes to generate (must be positive)
Throws
if size is not positive
Generates cryptographically secure random bytes using Web Crypto API.
Uses crypto.getRandomValues() which is available in all modern browsers and Node.js. This is the recommended way to generate cryptographic randomness in JavaScript environments.
Generates cryptographically secure random bytes using java.security.SecureRandom.
Generates cryptographically secure random bytes using libsodium.
Uses randombytes_buf() which is backed by the system CSPRNG (arc4random_buf on Apple platforms).