【发布时间】:2021-08-13 05:35:28
【问题描述】:
public static String DecryptKey() {
String decrypted = "";
String Key = "YKPADOWNUTXLQGCFVSRZHIBJME"
String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char [] alphaletters = Key.toCharArray();
for(int i = 0; i<alphaletters.length(); i++) {
//not sure what to put here in order to go through all of the letters in the key}
return decrypted;
因此,在这段代码中,我试图解密替换密码中给出的密钥。通过解密,我的意思是字母“Z”是字母“T”通常在普通字母表中的位置,在解密的字符串中,字母“T”将是最后一个,以便为每个字母解密消息等钥匙。但我不确定如何执行此操作,以便 for 循环将遍历密钥中的每个字母,同时检查其在普通字母表中的位置,然后返回解密的密钥。
【问题讨论】:
标签: java arrays loops for-loop encryption