Skip to content

Instantly share code, notes, and snippets.

@md5
Last active December 19, 2015 06:52
Show Gist options
  • Save md5/de5cea7195d757582621 to your computer and use it in GitHub Desktop.
Save md5/de5cea7195d757582621 to your computer and use it in GitHub Desktop.
Docker SecureRandom test

Instructions

$ git clone https://gist.github.com/de5cea7195d757582621.git docker-java-secure_random-test
$ cd docker-java-secure_random-test
$ docker build -t local/java-secure_random-test .
$ docker run --rm -it local/java-secure_random-test
FROM java:8
ENV TEST_SRC /usr/src/secure_random-test
RUN mkdir $TEST_SRC
WORKDIR $TEST_SRC
COPY SecureRandomTest.java $TEST_SRC/
RUN javac SecureRandomTest.java
CMD ["java", "-cp", ".", "SecureRandomTest"]
import java.math.BigInteger;
import java.security.SecureRandom;
public class SecureRandomTest {
public static void main(String... argz) throws Exception {
SecureRandom rnd = SecureRandom.getInstance("SHA1PRNG");
byte[] seed = rnd.generateSeed(1024);
System.out.println(new BigInteger(1, seed).toString(16));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment