-1
int main(void) {
char plain[6] = "lorem";
char cipher[27] = "nbajyfowlzmpxikuvcdegrqsth";
int length = strlen(plain);
char encrypted_text[6] = "pkcyx";
/*encryption*/
for (int i = 0 ; i < length ; i++) {
plain[i] = cipher[plain[i] - 97];
//printf("%c", plain[i]);
}
/*decryption*/
for (int i = 0 ; i < length ; i++) {
encrypted_text[i] = cipher index of encryted text.... how to write this...
eg: cipher index of o is 6 (0-n ,1-b, 2-a, 3-j, 4-y, 5-f, 6-o) ... i want this index so i + 97 will decrypt the msg
//printf("%c", plain[i]);
}
}
我想知道如何得到一個加密的信密碼指數?解密在C單字母替代密碼
@ jwdonahue感謝您的回覆! 我跑這個視覺工作室代碼,輸出:pkcyx(這將隨後被加密) 的#include 的#include INT主(無效){ 炭平原[6] = 「LOREM」; char cipher [27] =「nbajyfowlzmpxikuvcdegrqsth」; int length = strlen(plain); /* encryption */ for(int i = 0; i
Beansprout
如果給出 plain =「pkcyx」; cipher [27] =「nbajyfowlzmpxikuvcdegrqsth」; 要解密這個,我只能想到使用密碼的索引號和字母代表的+97來達到原始字母的小數。對於這種情況,p是密碼[11],11 + 97會給我108這是原始字母「l」(L的小寫字母)。 但我不知道如何編寫代碼。你能給我一些關於實現部分的提示嗎? – Beansprout