我需要编码一个替换密码加密器。但是,我不知道如何从pass密钥创建一个与正常字母表匹配的字母表,以便生成我的加密消息
它应该会给出这样的结果
String passphrase = "mobile";
byte[] expected = {'m', 'o', 'b', 'i', 'l', 'e', 'a', 'c', 'd', 'f' ...};
如何编写返回预期字母表的函数?
发布于 2020-10-03 04:06:02
顺便说一句,您真的应该使用char
数组。如果您确实不需要char数组,只需将所有内容强制转换为byte即可。
static char[] generateExpected(String passphrase) {
char[] expected = new char[passphrase.length() + 26];
passphrase.getChars(0, passphrase.length(), expected, 0);
for (int i = 0; i < 26; i++) {
expected[i + passphrase.length()] = (char) ('a' + i);
}
return expected;
}
https://stackoverflow.com/questions/64177266
复制相似问题