土耳其字母表的凯撒密码解密
Caesar cipher decryption for Turkish alphabet's
我在网上找到了很多例子,但找不到土耳其字母的凯撒密码解密。大多数字母与英语字母表相似,但也有一些不同以下是土耳其字母:
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
我找到了这个英文字母代码,它没有一些字母,如İ,Ö,Ü,Ş,ç, erdogan, yi,ö,
#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;
}
请帮我把这个工作为土耳其字母
您发布的示例代码依赖于标准拉丁字母是ASCII表中连续块的事实。但土耳其字母不是这样的,所以你必须用不同的方法来解决这个问题。
我建议您使用替换表。创建一个包含256个字符的数组(字符编码表中的每个代码点对应一个字符),并用应该使用的字母填充每个代码点。然后迭代输入文本并通过在该数组中查找来替换每个字符。
相关文章:
- AES加密到解密未正确输出
- 为什么这不是解密
- c++中的oop(密码生成)
- 密码登录程序将永远循环并显示不正确的结果
- 通过 Openssl 命令行加密,通过 c++ 解密
- OpenSSL没有共享密码
- OpenSSL 解密功能无法正常工作
- 仿射密码解密,输出大小写不同
- 运行密钥密码解密知道密钥?
- 凯撒密码在C++中无法正确解密的问题
- 简单仿射密码加密解密
- 使用 c++/openssl 使用密码解密文件
- AES/CFB密码模式从字符串失败中解密
- 当偏移量为 11 或更大时,解密 Caesar 密码将失败
- 上和小写字符串的加密和解密,基本密码C
- C++ 密码解密错误NTE_BAD_DATA
- 解密单字母密码到新的文本文件
- 尝试多个密钥进行 Caesar 密码解密从密钥 9 而不是 1 开始
- 解密Firefox密码库
- 土耳其字母表的凯撒密码解密