我正在尝试一个简单的 Vigenere 密码,其中从文件中读取纯文本并使用密钥进行加密。
Key =ABC 密文由PT和key相加得到
纯文本:WEWILLATTACKTONIGHT
键:ABCABCABCABCABCABCA
密码:WFYIMNAUVADMTPPIHJT
我怎样才能重复纯文本长度的密钥,然后在读取它时对其进行加密。?
使用以下代码段从文件中读取输入
FileInputStream fileInput = new FileInputStream("/Documents/file1.txt");
int r;
int count = 0 ;
//Read each character from the file one by one till EOF
while ((r = fileInput.read()) != -1)
{
char c = (char) r;
//SOMETHING NEEDS TO BE DONE HERE
System.out.print(c);
count ++; //Keeps count of the number of characters in the plain text.