用C 實現字串的加密解密操作

2022-03-15 08:05:44 字數 792 閱讀 9682

哈哈,最近剛剛開始學習c#,感覺挺好。

下面一段**是用c#實現的,主要完成對字串的加密和解密操作。

//源**

//對一段字串實現加密解密操作

using system;

using system.collections.generic;

using system.linq;

using system.text;

namespace study_test4

",arr[i]);      //輸出加密後的字元

/*對加密的字串進行解密*/

char arr_decode = new char[l];

arr_decode[l - 1] = arr[0];

for(int i = 1; i < l; i++)

arr_decode[i-1] = (char)((int)(arr[i])-3);

console.write("解密後:");

for (int i = 0; i < l; i++)

console.write("", arr_decode[i]);//輸出加密後的字元

console.readline();                    //讓控制台停在顯示介面}}

}

在學習c#的過程中,深切的知道,一段好的**是一定要有注釋的,因為寫出的**不僅僅是給自己看。所以為了養成寫注釋的習慣,雖然**很簡單,我也一一注釋了。

裡面不規範的地方,希望大家幫忙改正,謝謝啦o(∩_∩)o

用C 實現字串的加密解密操作

哈哈,最近剛剛開始學習c 感覺挺好。下面一段 是用c 實現的,主要完成對字串的加密和解密操作。源 對一段字串實現加密解密操作 using system using system.collections.generic using system.linq using system.text names...

字串加密解密

using system.security.cryptography using system.io 加密函式 static stirng encrypt string str descryptoserviceprovider descsp new descryptoserviceprovider ...

C 字串加密和解密

using system.security.cryptography using system.io 預設金鑰向量 private static byte keys des加密字串 待加密的字串 加密金鑰,要求為8位 加密成功返回加密後的字串,失敗返回源串 public static string ...