我在互联网上发现了很多例子,但是找不到土耳其字母表的Ceaser密码解密。大多数的字母类似英文字母,但也有一些区别 这里是土耳其字母:土耳其字母表的凯撒密码解密
A B C Ç D E F G Ğ H I İ J K L M N O Ö P R S Ş T U Ü V Y Z
a b c ç d e f g ğ h i ı j k l m n o ö p r s ş t u ü v y z
我发现英文字母的代码,它并没有一些字母像I,O,U,S,C,G,I,O,S,U:
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
using namespace std;
int main()
{
char code[501];
int shift, len, i=0, j=0;
cout << "Caesar Cipher Decoder " << endl;
cout << "\nThis program will decrypt the entered text using Caesar Cipher." << endl;
cout << "\nPress any key to continue...";
_getch();
system("cls");
cout << "Enter the text that has to be decrypted (max 500 characters):" << endl;
cin.getline(code, 501);
len = strlen(code);
while (j < len)
{
if(code[j] == 32)
{
code[j] = code[j];
}
j++;
}
po:
cout << "\nEnter the amount of Caseser Shift in numbers: ";
cin >> shift;
if ((shift > 26) || (shift < 0))
{
cout << "\nShift value should be less than or equal to 26. Type again." << endl;
goto po;
}
while (i < len)
{
code[i] = tolower(code[i]);
code[i] = code[i] - shift;
if (code[i] + shift == 32)
{
code[i] = code[i] + shift;
}
else if(
((code[i] + shift > 31) && (code[i] + shift < 65)
|| ((code[i] + shift > 90) && (code[i] + shift < 97))
|| ((code[i] + shift > 122) && (code[i] + shift < 128)))
)
{
code[i] = code[i] + shift;
}
else if (code[i] < 97)
{
if (code[i] == 32 - shift)
{
code[i] = code[i] + shift;
}
else
{
code[i] = (code[i] + 26);
}
}
i++;
}
system("cls");
cout << "\nYour deciphered code is: \"" << code << "\"" << endl;
cout << "\nYour text has been decrypted." << endl;
cout << "\nPress any key to end." << endl;
_getch();
return 0;
}
请帮我做这个工作,为土耳其字母表。
你有什么试过?你对你发布的代码有什么不了解?请更具体一些。 – RedX 2013-03-21 13:21:57
因为其中一些字符不是ASCII字符编码的一部分,所以首先需要使用比char更广泛的数据类型。您也不能简单地添加移位值,因为这将导致字符不是您的字母表的一部分 – msam 2013-03-21 13:27:50
我无法使用这些字母时,使用这些字母时,使加密或解密,例如,如果我移动1个字母“İ”与解密我应该有“我”为Turkhis字母表,但代码给“h”。我不知道也许是因为它的ASCII码,但我不知道如何为这段代码隐藏这些字母。 – thomas123 2013-03-21 13:28:45