All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.amazonaws.services.dynamodbv2.datamodeling.internal.Utils Maven / Gradle / Ivy

There is a newer version: 2.0.3
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy