今天沒事寫了乙個簡單的加密及解密演算法,主要是利用c#本身的安全des的演算法做。
step1
新建乙個簡單的form應用程式
step2
新建 乙個類
public static class security
;///
/// des加密字串
///
/// 待加密的字串
/// 加密金鑰,要求為8位
/// 加密成功返回加密後的字串,失敗返回源串
public static string encryptdes(string encryptstring, string encryptkey)
catch
}///
/// des解密字串
///
/// 待解密的字串
/// 解密金鑰,要求為8位,和加密金鑰相同
/// 解密成功返回解密後的字串,失敗返源串
public static string decryptdes(string decryptstring, string decryptkey)
catch}}
}step3
在應用程式裡呼叫
private void button1_click(object sender, eventargs e)
private void button2_click(object sender, eventargs e)
private void button1_click(object sender, eventargs e)
private void button2_click(object sender, eventargs e)
private void button1_click(object sender, eventargs e)
private void button2_click(object sender, eventargs e)
好了到此就寫完了沒事了。可以封裝好用於其它專案。免得寫那麼多幾行**!
DES加密解密
using system using system.drawing using system.collections using system.componentmodel using system.windows.forms using system.data using system.io us...
DES加密解密
加密類 date 2012 04 23 pm.public class encrypt private encrypt 建立加密類物件.public static encrypt createcryptoserviceprovider des加密.待加密字串.加密金鑰.8位 public strin...
DES加密解密
using system.data using system.configuration using system.web using system.web.security using system.web.ui using system.web.ui.webcontrols using syst...