/// <summary>
/// DES加密字符串
/// </summary>
/// <param name="encryptString">待加密的字符串
/// <param name="encryptKey">加密密钥,要求为8位
/// <returns>加密成功返回加密后的字符串,失败返回""</returns>
public static string EncryptDES(string encryptString)
{
try
{
//byte[] rgbKey = Encoding.UTF8.GetBytes(encryptKey.Substring(0, 8));
byte[] rgbKey = { 56, 104, 247, 80, 37, 100, 168, 4 };
byte[] rgbIV = { 103, 17, 94, 157, 79, 5, 219, 33 };//{ 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
byte[] inputByteArray = Encoding.UTF8.GetBytes(encryptString);
DESCryptoServiceProvider dCSP = new DESCryptoServiceProvider();
MemoryStream mStream = new MemoryStream();
CryptoStream cStream = new CryptoStream(mStream, dCSP.CreateEncryptor(rgbKey, rgbIV), CryptoStreamMode.Write);
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余3页未读,立即下载