c語言字串加密,C語言 字串加密

時間 2022-03-08 16:36:24

1樓:風雷九州

#include

#include

#include

int main(void)

else

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

else

}else

}printf("%s\n",c);

return 0;}

2樓:

string a = "welcome";

string b = null;

int num = a.length;

int ascii;

char ch;

b = a.substring(a.length - 1, 1);

for (int i = 0; i < num - 1; i++)messagebox.show("明文="+a +"密文="+b);

3樓:匿名使用者

有空格跳過就行了,如下

private string encrypt(string str)

if (char.isletter((char)(str[i] + 1)))

result += (char)(str[i] + 1);

else

result += (char)(str[i] - 25);

}return result;

}private string decrypt(string str)

if (char.isletter((char)(str[i] - 1)))

result += (char)(str[i] - 1);

else

result += (char)(str[i] + 25);

}return result;

}private void button1_click(object sender, eventargs e)

4樓:匿名使用者

private string encode(string value)

5樓:

stringbuilder str=new stringbuilder("hdkahdkjsahdkas",100);

for(int i=(int)'z';i>=(int)'a';i--)

for(int i=(int)'z';i>=(int)'a';i--)

console.writeline(str.tostring());

大概就這樣了,偷懶沒考慮沒考慮吧a—》z or a—》z

c語言怎麼加密字元

6樓:自我程式設計

我沒注意只要小寫,我寫的是大小寫都可以的,另外附送輸入驗證。

#include

#include

int main()

else

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

return 0;}

7樓:匿名使用者

c語言本身是不能加密字元的,但你可以寫乙個加密程式來加密。

為敘述方便,不妨設這個程式為jm。

給定乙個字串s,加密後的串為jm(s),我們稱之為密文,原串為明文。

只要有這麼乙個jm程式,就可以實現加密字元。

相對應的還有解密。

p.s.常用的加密方法有迴圈字串法、金鑰加密法

8樓:樂跑小子

#include

encode(char * s)

}main()

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

9樓:匿名使用者

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

10樓:匿名使用者

#include

#include

#include

#define data_size (1*1024)int main()

system("pause");

return 0;

}已經編譯通過的,上面幾位大俠說的也都對。

11樓:徐光豬

#include

void main()

puts(a);}

12樓:再騎莫克撞撞樹

function ec (byval s as string ,byval b as boolean ) as string

dim sx as string ,sout as stringdim i as integer ,n as integern=iif(b,5,-5)

for i =1 to len(s)

sx=mid(s,i,1)

sout=sout chr(asc(sx)+n)next

ec=sout

end fucntion

13樓:那壹抹嫣紅

char a[n];

int b[n];

for(int i=0; i

C語言拆分字串,C語言字串拆分

原始程式有錯 s要求char 引數 但是 sp i 為char型 應去掉 修改補充如下 include include void splitstr char s,char d if p 0 break p r i null d r int main include const int maxstrl...

c語言定義字串陣列,C語言 如何定義字串陣列

天方夜譚的哆啦a夢 c語言字串陣列中的每乙個元素均為指標,即有諸形如 ptr array i 的指標。由於陣列元素均為指標,因此ptr array i 是指第i 1個元素的指標。例 如二維指標陣列的定義為 char ptr array 3 擴充套件資料 字串陣列陣列元素表示方法 陣列元素的一般形式為...

c語言的字串宣告問題,C語言的字串宣告問題

簡單說一下 字串陣列是用來存放字串的陣列,在記憶體中佔一段連續的單元。所佔記憶體存放的是字串。定義方法為 char a n n為常量表示式,可初始化。字元指標是指向字元的指標,所佔記憶體單元存放的是所指字元的記憶體單元。定義方法為 char p 完整的解答 1 字元陣列由若干個元素組成,每個元素中放...

C語言中有哪些字串處理函式,C語言字串處理的庫函式有哪些

你可以看一下頭檔案string.h和stdio.h裡面的相關函式宣告,好多好多。這裡就不一一列出了 比如下面列出的只是其中一部分 crtimp char cdecl strcpy char const char crtimp char cdecl strcat char const char crt...

C語言關於字串的問題,C語言關於字串的乙個問題。。

你函式的功能是去處非字母字元,也就是刪除空格個!應該輸出itis 字串是自動加上結束識別符號的 0 遇到這個停止,但是輸出列印出來螢幕上看不到 暈,其實很簡單,因為空格就是空格符不是終止符號 0 c為從輸入的資料中取出的乙個字元,不應該是字串。比較是通過ascii編碼比較的。a z對應的ascii編...