我想创建一个vigenere密码的另外部分,并且需要在字母表中一起添加字母,导致字母表中的另一个字母。这必须是没有特殊字符的标准字母表。全部26个字母。 我可以得到与字母数字关联的数字。例如A = 0 B = 1 ... z = 25,那么我如何能够创建字符串充满相当于该数字的字母?如何添加导致字母表中另一个字母的字母?
public String encrypt(String orig, String iv, String key) {
int i, j, result;
String cipherText = "";
int b = iv.length();
//loops through the entire set of chars
for (i = 0; i < text.length; i += b) {
//Splits the char into block the size of the IV block.
for (j = 0; j < b; j++) {
//checks to for first block. If so, begains with iv.
if (i == 0) {
//adding the iv to the block chars
char one = text[j], two = iv.charAt(j);
result = (((iv.charAt(j) - 'a') + (text[j] - 'a')) % 26);
//prints out test result.
System.out.println(one + " + " + (iv.charAt(j) - 'a') + "= " + result);
} else {
//block chainging, addition, with new key.
result = ((key.charAt(j) - 'a') + (text[j + i] - 'a')) % 26;
// System.out.println(result);
}
}
}
return cipherText;
}
建议:添加更多标签,你的问题,如加密或这样,一个更好,如果你的标题清楚地表明,你在说密码 – gia