當前位置:首頁 » 密碼管理 » 凱撒密碼在線加密

凱撒密碼在線加密

發布時間: 2024-04-09 20:37:54

『壹』 凱撒密碼實現英文短句的加解密

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!=''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!=''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!=Ɗ') { if(ch0==Ƈ') { 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==ƈ') { 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==Ɖ') { 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中的值,實現字母移位,達到加密目的。

本程序提供解密功能/************************************************************************//* 版權所有:信息工程學院 王明 使用時請註明出處!! *//* 演算法:凱撒密碼體制 *//************************************************************************/#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!

『貳』 我喜歡你凱撒密碼

如果推進數字是3的話,這個凱撒密碼就可以是L ORYH BRX。

凱撒密碼是一種替換加密的技術,明文中的所有字母都在字母表上向後(或向前)按照一個固定數目進行偏移後被替換成密文。

例如,當偏移量是3的時候,所有的字母A將被替換成D,B變成E,以此類推。這個加密方法是以羅馬共和時期愷撒的名字命名的,當年愷撒曾用此方法與其將軍們進行聯系。

(2)凱撒密碼在線加密擴展閱讀

各國我愛你

1、英 語:I love you

2、法 語:Je t』aime,Je t』adore

3、德 語:Ich liebe dich

4、希 臘語:∑'αγαπώ(S』agapo)

5、猶 太語:אני אוהב אותך

6、匈 牙 利:Én is szeretlek

7、愛 爾 蘭:taim i』ngra leat

8、愛 沙 尼 亞:Mina armastan sind

9、芬 蘭:Min rakastan sinua

10、比 利 時佛蘭芒語:IK zie u graag

11、意 大 利語:ti amo,ti vogliobene

12、拉 丁語:Te amo,Vos amo

『叄』 I love you 的愷撒碼是什麼

如果推進數字是3的話,這個凱撒密碼就可以是L ORYH BRX。

I love you可以用520來表示。

520,是519與521之間的自然整數,網路語言中,「520」諧音「我愛您」。又如:5201314「我愛您一生一世」,520320179「我愛您想愛您一起走」。

(3)凱撒密碼在線加密擴展閱讀

五字開頭愛情數字密碼

一、5406 我是你的

二、5407 我是你妻

三、54064 我是你老師

四、5976 我到家了

五、52067我愛你不變

六、587129955我不介意愛朝朝暮暮(我不求與你

七、514我愛你一生一世

『肆』 求密文(凱撒密碼)

已知凱撒密碼的計算公式為 f(a)=(a+k) mod n,設k=3,n=26,明文P=COMPUTERSYSTEM,求密文。解:明文字母代碼表如下如下:由於k=3,對於明文P=COMPUTERSYSTEMf(C)=(2+3) mod 26=5=Ff(O)=(14+3) mod 26=17=Rf(M)=(12+3) mod 26=15=Pf(P)=(15+3) mod 26=18=Sf(U)=(20+3) mod 26=23=Xf(T)=(19+3) mod 26=22=Wf(E)=(4+3) mod 26=7=Hf(R)=(17+3) mod 26=20=Uf(S)=(18+3) mod 26=21=Vf(Y)=(24+3) mod 26=1=Bf(S)=(18+3) mod 26=21=Vf(T)=(19+3) mod 26=22=Wf(E)=(4+3) mod 26=7=Hf(M)=(12+3) mod 26=15=P所以密文C=Ek(P)=FRPSXWHUVBVWHP

熱點內容
不屬於編譯程序組成的部分是什麼 發布:2024-05-05 19:05:34 瀏覽:612
壓縮麵食 發布:2024-05-05 18:55:45 瀏覽:803
linux的gz解壓命令 發布:2024-05-05 18:24:13 瀏覽:311
伺服器機櫃屬於什麼輻射 發布:2024-05-05 18:02:10 瀏覽:336
存儲成本計算 發布:2024-05-05 18:02:10 瀏覽:584
如何把手機改安卓10 發布:2024-05-05 17:39:07 瀏覽:498
我的世界怎麼擴容伺服器內存 發布:2024-05-05 17:19:54 瀏覽:48
java讀取文件字元 發布:2024-05-05 17:15:18 瀏覽:11
三星怎麼應用加密 發布:2024-05-05 17:13:18 瀏覽:152
cad字體在那個文件夾 發布:2024-05-05 17:08:20 瀏覽:331