Here's a Java program that converts the data from compact binary representation to ASCII digits (requires Java 8 ):
Code:
import java.math.BigInteger;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class AMillionRandomDigits {
public static void main(String[] args) throws Exception {
Path inputPath = Paths.get("/tmp/AMillionRandomDigits.bin");
Path outputPath = Paths.get("/tmp/AMillionRandomDigits.txt");
byte[] inputInBinary = Files.readAllBytes(inputPath);
BigInteger inputAsNumber = new BigInteger(inputInBinary);
String inputInBase10 = inputAsNumber.toString();
Files.write(outputPath, inputInBase10.getBytes());
}
}
Output size is exactly 1e6 bytes.
Code:
$ sha1sum AMillionRandomDigits*
376f1d865ad3a1f92bd07033af200addfbacc436 AMillionRandomDigits.bin
e111bf84f27e46c260ef2713fc06070a8d2cfc36 AMillionRandomDigits.txt
Update:
Actually, you don't even need to run this code.
http://www.rand.org/publications/classics/randomdigits/ (which currently redirects to https://www.rand.org/pubs/monograph_reports/MR1418.html ) allows to directly download the digits as a formatted text file (current direct link is https://www.rand.org/content/dam/ran...digits.txt.zip ). You only need to strip formatting (spaces, new lines and first column with line numbers) and you're left with raw digits.