DES的加密解密

2021-07-16 08:33:54 字數 834 閱讀 1175

des的加密解密

des加密演算法是一種對稱加密演算法,很可能是使用最廣泛的金鑰系統,特別是在保護金融資料的安全中,最初開發的dea是嵌入硬體中的。

在vs中的使用非常的簡單,首先引用兩個命名空間,然後,需要的設定兩個引數,乙個是key值秘鑰,乙個是iv向量。

引用命名空間

usingsystem.io;

usingsystem.security.cryptography;

加密解密函式

//加密函式

public static string encrypt(string sourcestring, string key, string iv)

return convert.tobase64string(ms.toarray());

}catch}}

catch

return "des加密出錯";

} //解密函式

public static string decrypt(string encryptedstring, string key, string iv)

return encoding.utf8.getstring(ms.toarray());

}catch}}

新增兩個控制項,進行呼叫加密解密函式,一句話即可。

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...