#include<stdio.h>
#include<string.h>
#include<ctype.h>
int test(char* array);
int main()
{
char table[5][5]={'M','O','N','A','R','C','H','Y','B','D','E','F','G','I','K','L','P','Q','S','T','U','V','W','X','Y'};
table[4][4] = 'Z';
char x[50];
printf("请输入明文以加密:");
gets_s(x);
while (test(x) != 0) //将明文转换为合适的字母对
{
int i;
int k = test(x);
for (i = strlen(x) ; i > k; i--)
{
x[i+1] = x[i];
}
x[k+1] = 'x';
}
if (strlen(x) % 2 == 1)
{
int dick = strlen(x);
x[dick+1] =x[dick];
x[dick] = 'x';
}
int num;
for(int up=0;up<strlen(x);up++)
{
x[up] = toupper(x[up]);
}
for (num &#
Playfair密码
最新推荐文章于 2023-07-07 16:52:42 发布
Playfair密码是一种古典密码学中的替换密码,使用5x5矩阵进行字母替换,提高了单字母替换密码的安全性。该密码法通过特定规则将字母配对加密,其安全性在于不单独替换单个字母,而是考虑字母的相对位置。尽管现代密码学已发展出更高级的加密技术,但Playfair密码在历史上起到了重要作用,并启发了后续的密码设计。
摘要由CSDN通过智能技术生成