词条 | 凯撒算法 |
释义 | 凯撒密码是一种非常古老的加密方法,相传当年凯撒大地行军打仗时为了保证自己的命令不被敌军知道,就使用这种特殊的方法进行通信,以确保信息传递的安全。他的原理很简单,说到底就是字母于字母之间的替换 # include<stdio.h> main() { int key; char mingma,mima; printf("\ Please input the character:"); getch(); scanf("%c",&mingma); printf("\ Please input the key:"); getch(); scanf("%d",&key); if((mingma>='A')&&(mingma<='Z')) mima='A'+(mingma-'A'+key)%26; if((mingma>='a')&&(mingma<='z')) mima='a'+(mingma-'a'+key)%26; printf("\ The output is:%c",mima); getch(); } |
随便看 |
百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。