導航:首頁 > 文檔加密 > c語言英文版加密

c語言英文版加密

發布時間:2023-09-20 03:18:38

㈠ 用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>
#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 <string.h>
int main()
{
char passwd[100],encrypted[100];
int i,j,k,t,move;
while(1)
{
printf("Enter message to be encrypted:");

gets(passwd);

move=3;
for(i=0; i<strlen(passwd); i++)
{
if(passwd[i] >= 'A' && passwd[i] <= 'Z')
{

passwd[i] = ((passwd[i]-'A')+move)%26+'A';

} else if(passwd[i] >= 'a' && passwd[i] <= 'z')
{

passwd[i] = ((passwd[i]-'a')+move)%26+'a';

}

}

printf("%s",passwd);

printf("\n");

}
return 0;
}
這道題實際上就是C語言版的凱撒加密(字母往後面移動1-25之間的任意一位數)

㈤ c語言如何字母加密

//參考如下:

//先輸入要加密的字母
//再輸入往後移動幾位的參數
//最後輸出加密後的字母
//絕對簡單,又符合要求int main()

#include<stdio.h>

{
char c;
scanf("%c",&c);
int a;
scanf("%d",&a);
printf("%c ",c+a);
return 0;
}

㈥ C語言實現將字元串進行加密處理,每個字元的加密規則是,將其轉換為對應的ASCII碼加3後對應 的字元輸出

輸入的是英文字元的話,直接加3就可以,但是如果是中文字元的話,如果直接高位和地位加3也可以,但是解密的時候就有一個不確定的存在,因為中文字元的ascii編碼是有0xfe這樣的存在,加上3的話就到時候還原就變得不確定。所以如果是中文字元加密的話,應該把兩個ascii碼轉合並為兩個位元組無符號類型,然後再加3。

㈦ 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語言英文文本加密

#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語言英文版加密相關的資料

熱點內容
pdf打開後是空白 瀏覽:148
python量化交易pdf 瀏覽:725
照片如何加密不佔內存 瀏覽:965
手機怎麼下載小恆錢包app 瀏覽:849
閃電伺服器是什麼 瀏覽:111
單片機入門視頻教程第二課 瀏覽:45
天然氣可壓縮多少倍 瀏覽:238
程序員面試評價 瀏覽:128
手錶加密門禁卡 瀏覽:238
psf已加密 瀏覽:553
返利app怎麼用教程 瀏覽:888
一個程序員寫的詩火了 瀏覽:613
red攝影機壓縮比 瀏覽:410
app賬號怎麼弄 瀏覽:823
hc0551單片機 瀏覽:755
噴淋管道支架演算法 瀏覽:592
壓縮機壞了電腦無法啟動 瀏覽:242
不小心加密了怎麼去掉 瀏覽:955
linux命令行連接db2 瀏覽:899
洪恩app怎麼設置護眼模式 瀏覽:971