導航:首頁 > 文檔加密 > c語言加密單詞代碼

c語言加密單詞代碼

發布時間:2024-04-05 13:45:38

㈠ C語言題編程實現對鍵盤輸入的大寫英文字母進行加密。字母

#include<stdio.h>
#include<ctype.h>
intmain()
{inti;
chars[200];
gets(s);
for(i=0;s[i];i++)
if(isalpha(s[i]))
{s[i]+=3;
if(s[i]%0x20>26)s[i]-=26;
}
puts(s);
return0;
}

㈡ C語言 簡單對字母進行加密

1、在我們的編輯頁面輸入以下代碼。

㈢ C語言英文文本加密

#include "stdio.h"

#include <stdlib.h>

int main(int argc,char *argv[]){

FILE *fp,*fq;

int k,t;

fp=fopen("AAA12345678901.txt","w+");

if(!fp || (fq=fopen("tmp.txt","w"))==NULL){

printf("Failed to open the file and exit... ");

return 0;

}

printf("Please enter a short passage(letters+space+punctuation,'Enter' end)... ");

while((t=getchar())!=' ')//為文件輸入內容

fputc(t,fp);

printf("Please enter the encryption key(int >0)... k=");

while(scanf("%d",&k)!=1 || k<1){//輸入加密密鑰並判斷是否正確

printf("Input error, redo: ");

fflush(stdin);

}

rewind(fp);

while(t=fgetc(fp),!feof(fp))//加密

if(t>='A' && t<='Z')

fputc(((t-'A')+k)%26+'A',fq);

else if(t>='a' && t<='z')

fputc(((t-'a')+k)%26+'a',fq);

else

fputc(t,fq);

fclose(fp);//關閉原文件

fclose(fq);//關閉加密後的文件

remove("AAA12345678901.txt");//刪除原文件

rename("tmp.txt","AAA12345678901.txt");//將加密後的文件更換為原文件名

printf(" ");

if(fp=fopen("AAA12345678901.txt","r")){

while((t=fgetc(fp))!=EOF)

printf("%c",t);

printf(" Encryption success! ");

}

else

printf(" Failed to open the encrypted file... ");

fclose(fp);

return 0;

}

代碼格式和運行樣例圖片:

㈣ c語言字母加密

按照你的要求編寫的字母加密的C語言程序如下

(姓字母向後移兩位,名字母向後移三位)

#include<stdio.h>

#include<string.h>

int main(){

char src[30],result[]="",ch[2]={''};

int i,j,len;

fgets(src,30,stdin);

len=strlen(src);

for(i=0;src[i]!=' ';i++){

if('a'<=src[i] && src[i]<='z'){

ch[0]=(char)(((src[i]-'a')+2)%26+'a');

strcat(result,ch);

}else if('A'<=src[i] && src[i]<='Z'){

ch[0]=(char)(((src[i]-'A')+2)%26+'A');

strcat(result,ch);

}else{

ch[0]=src[i];

strcat(result,ch);

}

}

for(j=i;j<len;j++){

if('a'<=src[j] && src[j]<='z'){

ch[0]=(char)(((src[j]-'a')+3)%26+'a');

strcat(result,ch);

}else if('A'<=src[j] && src[j]<='Z'){

ch[0]=(char)(((src[j]-'A')+3)%26+'A');

strcat(result,ch);

}else{

ch[0]=src[j];

strcat(result,ch);

}

}

printf("%s ",result);

return 0;

}

㈤ C語言對字元進行加密

if(e>='A'&&e<='W')//
e+=3;
elseif(e>='X'&&e<='Z')
e-=23;
else
{
...//donotencryptordosomethingelse
}

㈥ C語言怎麼加密字元

#include<stdio.h>
#include<string.h>
intmain()
{
charstr[]="00000",str2[]="00000",*p=str,*p2=str2;
printf("輸入5個字母:");
while(*p!=0)
{
scanf("%c",p);
if(*p==' ')
continue;
if(*p<'A'||(*p>'Z'&&*p<'a')||*p>'z')//輸入驗證,必須是字母
{
printf("只能輸入字母,請重新輸入 ");
p=str;
p2=str2;
fflush(stdin);//輸入有錯重新輸入前清空緩沖區。fflush屬於c擴展函數,正常使用沒問題,如需在linuxggc上使用,考慮多次調用getchar函數來清空
}
else
{
*p2=(*p)+4;
if(*p2>90&&*p2<97)//大寫字母加4,最大位不超出
*p2='A'+(*p2-90)-1;
if(*p2>122)//小寫字母加4,最大位不超出
*p2='a'+(*p2-122)-1;
p2++;
p++;
}
}

printf("原字元串為:%s 加密後的字元串為:%s ",str,str2);
return0;
}

㈦ c語言:數據加密,加密規則是:將單詞中的每一個字母變成其後的第四個

給你個參考吧:

voidshift4(char*s){
chartemp[256];
for(inti=0;i<strlen(s);i++){
temp[i]=s[i];
}
for(inti=0;i<strlen(s);i++){
s[i]=temp[(i+4)%strlen(s)];
}
}
voidmain(){

char s[] = "abcdefgh";

shift4(s);

cout << s;

}

㈧ 鐢–璇璦緙栧啓涓涓鍔犲瘑紼嬪簭瀛楁瘝瀵圭収鐨 鍘熷瓧姣峚 b c d e i k , w 鍔犲瘑鍚巃 w k , i a b c e

鍋氫竴涓鏁扮粍錛孋[255]
a鐨凙SCII鐮佷負95錛宐鐨勬槸96錛屼緷嬈°傘傘
c[95]=95,c[96]='w',c[97]='k'
榪欐牱杈撳嚭鐨勫瓧涓詫紝灝辮佸瑰簲鍒版暟緇勫幓鍙
姣斿俤[1]=c[a[1]]

㈨ 用C語言編程實現對鍵盤輸入的英文名句子進行加密

#include<stdio.h>

void main()

{

char str1[256],str2[256],*p,*q;
int x;
gets(str1); p=str1; q=str2;
while ( *p )
{ if ( (*p)>='A' && (*p)<='Z' )
{ x=(*p)-'A';
x++; (*q)=x%26+'A'; q++;
x++; (*q)=x%26+'A'; q++;
x++; (*q)=x%26+'A';
}
else if ( (*p)>='a' && (*p)<='z' )
{ x=(*p)-'a';
x++; (*q)=x%26+'a'; q++;
x++; (*q)=x%26+'a'; q++;
x++; (*q)=x%26+'a';
}
else (*q)=(*p);
p++; q++;
}
(*q)=0; printf("%s ",str2);}

}

㈩ C語言將小寫字母加密

#include<stdio.h>

int main()

{

char s[100];

int i;

gets(s);

for(i=0;s[i];i++)

if (s[i]>='a'&&s[i]<='z')

{

s[i]+=2;

if(s[i]>'z')s[i]-=26;

}

puts(s);

system("pause");

return 0;

}

閱讀全文

與c語言加密單詞代碼相關的資料

熱點內容
男人懷孕電影袋鼠男人 瀏覽:506
如何刪去應用加密 瀏覽:468
服從命令聽指揮陌千依小說 瀏覽:761
《赤足驚魂》電影介紹 瀏覽:358
ic卡內數據如何傳到伺服器 瀏覽:21
安卓系統如何更改托盤 瀏覽:403
許志安演的電影有哪些 瀏覽:824
odbc文件夾是什麼 瀏覽:391
男主用鐵鏈囚禁女主的小說 瀏覽:914
sift演算法harris演算法 瀏覽:241
python命令行模式 瀏覽:459
新媽媽韓國電影中的輔導老師是誰 瀏覽:389
php郵箱驗證代碼 瀏覽:404
光貓偽裝命令 瀏覽:175
安卓高端機為什麼都用曲屏 瀏覽:419
老電影大全 戰爭片 瀏覽:971
有沒有小電影得網址網站 瀏覽:378
奧特曼電影排行榜前十名 瀏覽:580
安卓光遇賬號過期怎麼找回 瀏覽:476