com.amazonaws.services.dynamodbv2.datamodeling.internal.Utils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aws-dynamodb-encryption-java Show documentation
Show all versions of aws-dynamodb-encryption-java Show documentation
AWS DynamoDB Encryption Client for AWS Java SDK v1
package com.amazonaws.services.dynamodbv2.datamodeling.internal;
import java.security.SecureRandom;
public class Utils {
private static final ThreadLocal RND = new ThreadLocal() {
@Override
protected SecureRandom initialValue() {
final SecureRandom result = new SecureRandom();
result.nextBoolean(); // Force seeding
return result;
}
};
private Utils() {
// Prevent instantiation
}
public static SecureRandom getRng() {
return RND.get();
}
public static byte[] getRandom(int len) {
final byte[] result = new byte[len];
getRng().nextBytes(result);
return result;
}
}