// An highlighted block
#include <stdio.h>
int N=26;
int exgcd(int a, int n) {
int p = a, q = n;
int x = 0, y = 1;
int z = q / p;
while (p != 1 && q != 1) {
int t = p;
p = q % p;
q = t;
t = y;
y = x - y * z;
x = t;
z = q / p;
}
y %= n;
if (y < 0) y += n;
return y;
}
void main()
{ int a,b;
char ch[1000];printf("输入明文");gets (ch);
printf("输入秘钥ab\n");
scanf("%d",&a);
scanf("%d",&b);
d=exgcd(a,26);
int i=0;
char re[1000];
while (ch [i]!= '\0')
{
if ((int)ch [i]>= 65 && (int)ch[i] <= 90)//判断字符是否介于<A,Z>
{
re[i] = (char)(((a*((int)ch [i]- 65) + b) % N) + 65);
printf("%c",re[i]);
}
if ((int)ch [i]>= 97 && (int)ch [i]<= 1
c语言仿射密码和维吉尼亚密码仿射密码// An highlighted block#include <stdio.h>int N=26;int exgcd(int a, int n) { int p = a, q = n; int x = 0, y = 1; int z = q / p; while (p != 1 && q != 1) { int...