com.ionic.sdk.core.rng.RNG Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ionic-sdk Show documentation
Show all versions of ionic-sdk Show documentation
The Ionic Java SDK provides an easy-to-use interface to the Ionic Platform.
package com.ionic.sdk.core.rng;
import java.security.SecureRandom;
/**
* Utility functions relating to the JRE random number generator facility.
*/
public final class RNG {
/**
* Constructor.
* http://checkstyle.sourceforge.net/config_design.html#FinalClass
*/
private RNG() {
}
/**
* Generate some random bytes, to be used in cryptographic operations.
*
* The empty argument constructor is used in preference to any particular implementation. This defers the choice
* of random number generator to the system.
*
* Once support for JRE 1.7 is dropped (JRE 1.8+), we may choose to migrate to use
*
* getInstanceStrong.
*
* @param bytes the byte array to be filled with random data
* @return the parameter byte array, populated with secure random data
* @see
* SecureRandomImpl (oracle.com)
* @see
* Stack Overflow
* @see
* googleblog.com
*/
public static byte[] fill(final byte[] bytes) {
new SecureRandom().nextBytes(bytes);
return bytes;
}
}