I am trying to pick up cryptography and had been trying this exercise
Write a program (preferably Java) to generate a one-time pad, which is a relatively large file
For the one time pad you need a byte array, not hexadecimals. The hexadecimals are only required for displaying data (we tend to have trouble reading bits). You can use the Apache Commons libraries (codec package) to create hexadecimals from byte arrays, or back if you want to decode the test vectors from hexadecimals to bytes.
You should use a secure random number generator, not Random
. So use new SecureRandom()
instead. To generate random data, first create a byte array, then call nextBytes()
on the random number generator. There is not need to generate integers.