I'm trying to pick up cryptography and tried this exercise
Write a program (preferably Java) to create a one-time pad, which is a relatively large file of all random data (say 1 MB). The program should also be able to encrypt / decrypt files based on the one generated.
Tip. Use the following test vector to verify that your program is properly encrypted.
Plaintext (ASCII): each cloud has a silver lining
OTP (HEX): 6dc72fc595e35dcd38c05dca2a0d2dbd8e2df20b129b2cfa29ad17972922a2
Encrypted Text (HEX): 28b14ab7ecc33ea157b539ea426c5e9def0d81627eed498809c17ef9404cc5
I tried to create a one-time block using a random number generator, since I need to convert them to a HEX form. and Iām sure that I am confused or did not solve it correctly.
public static void oneTimePad() { Random ran = new Random(); String s = "0123456789ABCDEF"; for(int i = 0; i < 100; i++) { System.out.print(s.charAt(ran.nextInt(s.length()))); } }
My disposable notepad would be higher, and I was wondering, like any idea, how I can implement encryption using one-time input and decrypting it.
user1792962
source share