C语言实现凯撒加密解密
#include <stdio.h>//加密int encryp(char *str,int key){char *p=str;while(*p!='\0'){//加上key然后取模*p=(*p-'a'+key)%26+'a';p++;}return 1;}//解密int decryp(char *str,int key){char *p=str;while(*p!='\0'){//避免负数取模为负数加上26*p=(*p-'a'-key+26)%26+'a';p++;}return 1;}void main(){char s[100];int key;printf("string:");scanf("%s",s);printf("key:");scanf("%d",&key);encryp(s,key);printf("ciphertext:%s\n",s);decryp(s,key);printf("cleartext:%s",s);}