Professional Documents
Culture Documents
One Time Pad in C++
One Time Pad in C++
and encrypt data step 4 : open output file(cipher.txt) to write decrypted data step 5 : initilize alpha[]="abcdefghijklmnopqrstuvwxyz" step 6 : generate random one time key step 7 : call function encryptFile(input file, output file,random key) step 8 : To write decrypted message, open file cipher.txt step 9 : call function decryptFile(output file ,randomly generated key) step 10 : stop procedure encryptFile(input file,output file, key) ------------------------------------------------step 1 : while(end of input file ) a)read data from file and store to array plaintext[] b)set J=0 c)loop : i=0 to length of plaintext (1)ch <- (plaintext[i] ^key[j++])+'a'; (2)print ch (3)add ch to output file (4)if J>=length of key ,then set J=0 end loop end procedure procedure decryptFile(output file, key) -----------------------------------------------step 1: while(end of output file) (a)read data from file and store to array ciphertext[] b)set J=0 c)loop : i=0 to length of ciphertext (1)ch <- (ciphertext[i]-++])+'a')^key[j++]) (2)print ch (3)if J>=length of key ,then set J=0 end loop end procedure