凯撒密码实现英文短句的加解密

作者&投稿:殳劳 (若有异议请与网页底部的电邮联系)
~

1. 将“We are students.”这个英文词句用k=4的凯萨密码翻译成密码

1. 恺撒密码,

作为一种最为古老的对称加密体制,他的基本思想是:

通过把字母移动一定的位数来实现加密和解密。

例如,如果密匙是把明文字母的位数向后移动三位,那么明文字母B就变成了密文的E,依次类推,X将变成A,Y变成B,Z变成C,由此可见,位数就是凯撒密码加密和解密的密钥。

如:ZHDUHVWXGHQWV(后移三位)

2. 凯撒密码,

是计算机C语言编程实现加密和解密。挺复杂的。你可以研究一下哦。

2. 将凯撒密码(K=7)的加密、解密过程用C语言编程实现

/*

声明:MSVC++6.0环境测试通过

*/

#include<stdio.h>

#include<ctype.h>

#define maxlen 100

#define K 7

char *KaisaEncode(char *str)//加密

{

char *d0;

d0=str;

for(;*str!='\0';str++)

{

if(isupper(*str))

*str=(*str-'A'+K)%26+'A';

else if(islower(*str))

*str=(*str-'a'+K)%26+'a';

else

continue;

}

return d0;

}

char *KaisaDecode(char *str)//解密

{

char *d0;

d0=str;

for(;*str!='\0';str++)

{

if(isupper(*str))

*str=(*str-'A'-K+26)%26+'A';

else if(islower(*str))

*str=(*str-'a'-K+26)%26+'a';

else

continue;

}

return d0;

}

int main(void)

{

char s[maxlen];

gets(s);

puts(KaisaEncode(s));

puts(KaisaDecode(s));

return 0;

}

3. 将凯撒密码X的加密、解密过程用C语言编程实现

(2)kaiser加密算法 具体程序:#include #include char encrypt(char ch,int n)/*加密函数,把字符向右循环移位n*/ { while(ch>='A'&&ch='a'&&ch<='z') { return ('a'+(ch-'a'+n)%26); } return ch; } void menu()/*菜单,1.加密,2.解密,3.暴力破解,密码只能是数字*/ { clrscr(); printf("
========================================================="); printf("
1.Encrypt the file"); printf("
2.Decrypt the file"); printf("
3.Force decrypt file"); printf("
4.Quit
"); printf("=========================================================
"); printf("Please select a item:"); return; } main() { int i,n; char ch0,ch1; FILE *in,*out; char infile[20],outfile[20]; textbackground(BLACK); textcolor(LIGHTGREEN); clrscr(); sleep(3);/*等待3秒*/ menu(); ch0=getch(); while(ch0!='4') { if(ch0=='1') { clrscr(); printf("
Please input the infile:"); scanf("%s",infile);/*输入需要加密的文件名*/ if((in=fopen(infile,"r"))==NULL) { printf("Can not open the infile!
"); printf("Press any key to exit!
"); getch(); exit(0); } printf("Please input the key:"); scanf("%d",&n);/*输入加密密码*/ printf("Please input the outfile:"); scanf("%s",outfile);/*输入加密后文件的文件名*/ if((out=fopen(outfile,"w"))==NULL) { printf("Can not open the outfile!
"); printf("Press any key to exit!
"); fclose(in); getch(); exit(0); } while(!feof(in))/*加密*/ { fputc(encrypt(fgetc(in),n),out); } printf("
Encrypt is over!
"); fclose(in); fclose(out); sleep(1); } if(ch0=='2') { clrscr(); printf("
Please input the infile:"); scanf("%s",infile);/*输入需要解密的文件名*/ if((in=fopen(infile,"r"))==NULL) { printf("Can not open the infile!
"); printf("Press any key to exit!
"); getch(); exit(0); } printf("Please input the key:"); scanf("%d",&n);/*输入解密密码(可以为加密时候的密码)*/ n=26-n; printf("Please input the outfile:"); scanf("%s",outfile);/*输入解密后文件的文件名*/ if((out=fopen(outfile,"w"))==NULL) { printf("Can not open the outfile!
"); printf("Press any key to exit!
"); fclose(in); getch(); exit(0); } while(!feof(in)) { fputc(encrypt(fgetc(in),n),out); } printf("
Decrypt is over!
"); fclose(in); fclose(out); sleep(1); } if(ch0=='3') { clrscr(); printf("
Please input the infile:"); scanf("%s",infile);/*输入需要解密的文件名*/ if((in=fopen(infile,"r"))==NULL) { printf("Can not open the infile!
"); printf("Press any key to exit!
"); getch(); exit(0); } printf("Please input the outfile:"); scanf("%s",outfile);/*输入解密后文件的文件名*/ if((out=fopen(outfile,"w"))==NULL) { printf("Can not open the outfile!
"); printf("Press any key to exit!
"); fclose(in); getch(); exit(0); } for(i=1;i<=25;i++)/*暴力破解过程,在察看信息正确后,可以按'Q'或者'q'退出*/ { rewind(in); rewind(out); clrscr(); printf("==========================================================
"); printf("The outfile is:
"); printf("==========================================================
"); while(!feof(in)) { ch1=encrypt(fgetc(in),26-i); putch(ch1); fputc(ch1,out); } printf("
========================================================
"); printf("The current key is: %d
",i);/*显示当前破解所用密码*/ printf("Press 'Q' to quit and other key to continue。


"); printf("==========================================================
"); ch1=getch(); if(ch1=='q'||ch1=='Q')/*按'Q'或者'q'时退出*/ { clrscr(); printf("
Good Bye!
"); fclose(in); fclose(out); sleep(3); exit(0); } } printf("
Force decrypt is over!
"); fclose(in); fclose(out); sleep(1); } menu(); ch0=getch(); } clrscr(); printf("
Good Bye!
"); sleep(3); }。

4. 怎样编写程序:实现恺撒密码加密单词"julus"

用下面程序:新建个txt,放进去任意单词,设置#define N 5中的值,实现字母移位,达到加密目的。

本程序提供解密功能/************************************************************************//* 版权所有:信息工程学院 王明 使用时请注明出处!! *//* 算法:凯撒密码体制 e799bee5baa6e4b893e5b19e31333264643062 *//************************************************************************/#include #define N 5void jiami(char namea[256]) { FILE *fp_jiami,*fp_file2; char c; fp_jiami=fopen(namea,"rb"); fp_file2=fopen("file2.txt","wb"); while(EOF!=(fscanf(fp_jiami,"%c",&c))) { if((c>='A'&&c='a'&&c='A'&&c='a'&&c='a'&&c='A'&&c='a'&&c='A'&&c='a'&&c='A'&&c<='Z')c=c+32; } fprintf(fp_file3,"%c",c); } fclose(fp_file3); fclose(fp_jiemi); }int main(){ char name[256]; int n; printf("输入你要操作的TXT文本:"); gets(name); printf("
请选择需要进行的操作:
"); printf(" 1:加密 2:解密
"); printf("输入你的选择:"); scanf("%d",&n); switch(n) { case 1:{jiami(name);printf("加密成功!!

"); break;} case 2:{jiemi(name);printf("解密成功!!

"); break;} default:{printf("输入操作不存在!");} } return 0;}。

5. 谁有PYTHON编写的凯撒密码的加密和解密代码

给你写了一个.

def convert(c, key, start = 'a', n = 26):

a = ord(start)

offset = ((ord(c) - a + key)%n)

return chr(a + offset)

def caesarEncode(s, key):

o = ""

for c in s:

if c.islower():

o+= convert(c, key, 'a')

elif c.isupper():

o+= convert(c, key, 'A')

else:

o+= c

return o

def caesarDecode(s, key):

return caesarEncode(s, -key)

if __name__ == '__main__':

key = 3

s = 'Hello world!'

e = caesarEncode(s, key)

d = caesarDecode(e, key)

print e

print d

运行结果:

Khoor zruog!

Hello world!




小众文案短句干净治愈英文
小众文案短句干净治愈英文。1、Have you somewhat to do tomorrow, do it today.明天如有事,今天就去做。2、The shortest answer is doing.最简短的回答就是行动。3、Dream, is a goal, is a prime mover, live is to make yourself happy.4、Courtesy, honesty, people and things.5、Of al...

国外文学家的短句
1、Tears is false, is really sad, after a thousand years without you I do not. 眼泪是假,悲哀是真,一千年以后没有你也没有我。 ——马克·吐温 2、Comity is such a kind of intense emotion of sanciticy is thus sweet, firm and honest. 友谊是如此圣洁的一种激情,是如此甜蜜、牢固和忠诚。

六个左右单词英文短句
1. 请各位帮忙造几个句子【英文】不要太难也不要太简单6个单词以上例 lie :The little boy often lies to his father.这个小男孩经常向父亲撒谎.He lied about his age.他在年龄上撒谎了.attack; The enemy attacked our airport last night.敌人昨夜攻击了我们的机场.talent; He had a talent for music....

英语短句佳句励志
1、I love it when I catch you looking at me then you smile and look away. 我喜欢这样的时刻:我抓到你正在看我,你笑了,然后害羞地别过脸去。 2、The road of life is like a large river,because of the power of the currents,river courses appear unexpectedly where there is no flowing water...

psf三个字母开头能组成什么英文短句?
pill over 撒出来l sell out 卖光 full of 满满的,

纹身英文短句励志热血
3. 求个,励志点的英文短句,想纹身 1. a bold attempt is half success.(勇敢的尝试是成功的一半。) 2. one today is worth two tomorrows.(一个今天胜似两个明天。) 3. knowing something of everything and everything of something.(通百艺而专一长。) 4. the shortest answer is doing.(最简单的回答...

英文美文短句
More never happy. 49、这个夏天放假后,我们就没有开学了。 After the summer vacation, we will not have a school. 50、成长是缓缓流淌的溪流。悄然地,我们就长大了。 Growth is a slow flowing stream. Quietly, we have grown up. 51、这一次相遇,美得彻骨,美得震颤,美得孤绝,美得惊艳。 Meet this...

友谊的英文句子唯美短句
1. “One loyal friend is worth ten thousand relatives.”2. 希望我是一个让你心动的人而不是权衡取舍分析利弊后觉得不错的人.3. 有些人不离开你,你永远长不大。4. 我们必须接受失望,因为它是有限的,但千万不可失去希望,因为它是无穷的。5. 时间为证,岁月为名。6. 遗忘是我们不可更改...

2020情人节浪漫告白的英文语录短句
2021情人节浪漫短句 1、 人走了心碎了,出门掉进泥坑了;你走了天暗了,处处跟我作对了;伤你了天罚我,吓的不敢出门了;亲爱的原谅我,否则要变宅男了。 2、 点播你热爱的口味搭配健康的早餐,收藏你欣赏的自信拥抱新的一天,然后用微笑带上门,出发,开始美丽,早上好。 3、 爱情是种缘分,我们要好好珍惜。所以,我...

清晨的阳光唯美句子短句英文
1. 太阳一到秋天,就将它的光芒全撒向人间。瞧,田野是金黄的,场地是金黄的,群山也是金黄的。2. 关于健康的诗句10句 3. Perseverance can sometimes equal genius in its results.4. 天空被夕阳染成了血红色,桃红色的云彩倒映在流水上,整个江面变成了紫色,天边仿佛燃起大火。5. 在这个世界上,...

铜山县13096063944: 将“We are students.”这个英文词句用k=4的凯萨密码翻译成密码. -
章性欣瑞:[答案] 1. 恺撒密码, 作为一种最为古老的对称加密体制,他的基本思想是: 通过把字母移动一定的位数来实现加密和解密. 例如,如果密匙是把明文字母的位数向后移动三位,那么明文字母B就变成了密文的E,依次类推,X将变成A,Y变成B,Z变成C,由此...

铜山县13096063944: 怎样编写程序:实现恺撒密码加密单词"julus" -
章性欣瑞: 用下面程序:新建个txt,放进去任意单词,设置#define N 5 中的值,实现字母移位,达到加密目的. 本程序提供解密功能 /************************************************************************/ /* 版权所有:信息工程学院 王明 使用时请注明出处!! ...

铜山县13096063944: 字符串“I love you ”,如果用凯撒密码,则加密后的密文为 -
章性欣瑞: 是 l oryh brx. 比如说密匙是1,那对英文单词book这个单词加密,结果就是相应的每个字母在字母表中的序号减去1,比如b在英文单词里排第二位. 那加密后就是a,o加密后就是n,依此类推,book加密后就是annj,解密时每个字母的顺序号加1,所对应的字母就是密文. 扩展资料: 凯撒密码使用方法: 奥古斯都也使用过类似方式,只不过他是把字母向右移动一位,而且末尾不折回.每当他用密语写作时,他都用B代表A,C代表B,其余的字母也依同样的规则;他用A代表Z. 另外,有证据表明,恺撒曾经使用过更为复杂的密码系统:文法学家普罗布斯曾经写过一份独具创新的手稿,研究恺撒书信中包含有秘密信息的字母.

铜山县13096063944: 凯撒密码 -
章性欣瑞: 凯撒密码关键的是密匙,密匙也就是一个数字,比如说密匙是1,那对英文单词book这个单词加密,结果就是相应的每个字母在字母表中的序号减去1,比如b在英文单词里排第二位,那加密后就是a,o加密后就是n,依此类推,book加密后就是annj,解密时每个字母的顺序号加1,所对应的字母就是密文.

铜山县13096063944: 用C#实现凯撒密码算法.急急急!! -
章性欣瑞: 你好,凯撒算法的原理很简单,就是对字母进行移位,比如最常用的右移3位. 比如字符'a'变成'd',字母'Z'变成'C'. 以下是一个凯撒算法加解密的示例程序,楼主可以参考: // Copyright @ quark // Date: 2010-10-23 using System; namespace ...

铜山县13096063944: 求凯撒密码编程实验?
章性欣瑞: 凯撒加密(JAVA版的,亲,不要太感谢我,求采纳- -!!): public class Encryption { private static char encry(char c){ if(c>=97 && c<=123){ if(c == 'x'){ c = 'a' ; }else if(c == 'y'){ c = 'b' ; }else if(c == 'z'){ c = 'c' ; }else{ c = (char) (c+3) ; } } return c ; } ...

铜山县13096063944: 明文:Electronic business is very important 要求:用凯撒密码进行加密,k=2,向后加密. -
章性欣瑞: 步骤:新建txt文本文件,把“Electronic business is very important”放进去,运行程序.本程序实现加密解密功能 加密解密文件在C文件目录下找~/************************************************************************//* 版权所有:信息工程学院 王明 ...

铜山县13096063944: 恺撒密码是什么?
章性欣瑞: 密码的使用最早可以追溯到古罗马时期,《高卢战记》有描述恺撒曾经使用密码来传递信息,即所谓的“恺撒密码”,它是一种替代密码,通过将字母按顺序推后起3位起到加密作用,如将字母A换作字母D,将字母B换作字母E.因据说恺撒是...

铜山县13096063944: 求解凯撒密码算法的题目 -
章性欣瑞: C的编程思路,其它的语言不会 1,用for循环,实现一维数组a【】,从第一个输入到第六个字母,然后再用for循环把a【】从0到5都减29,赋值到b【】,把数组b以字符变量输出 2,同理,把密文加29,然后以字符变量输出 具体程序不难,我这里没有c编译软件.....

铜山县13096063944: 加密解密“恺撒密码”有C语言高手没?只用C做哦!万分感激 -
章性欣瑞: 一次性不让发这么多代码.所以分2个部分发给你,然后你直接拼起来就是了,我编了一个晚上才达到这样的效果,分一定要给我啊!不容易啊!~~~其实我也是初学者!绝对可以达到你想要的效果!用TC也可以编译的. #include #include #include ...

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网