md5加密:
#region md5加密
/// /// 利用 md5 加密演算法加密字串
///
/// 字串源串
/// 返加md5 加密後的字串
public static string computemd5(string src)
/// /// 將指定串加密為不包含中槓的md5值
///
/// 要加密的字串
/// 返回值的大小寫(true大寫,false小寫)
///
public static string computemd5(string str, bool isupper)
/// /// 將字串翻譯成位元組陣列
///
/// 字串源串
/// 位元組陣列
private static byte getbytearray(string src)
return bytearray;
}#endregion
sha1加密:
#region sha1加密
public string sha1(string source_string)
return entext.tostring();
}#endregion
des加密解密:
private const string _encryptdes = "hylanc80";
#region des加密與解密
/// /// des加密字串
///
/// 待加密的字串
/// 加密金鑰,要求為8位
/// 加密成功返回加密後的字串,失敗返回源串
public static string encryptdes(string encryptstring,string key)
;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);
cstream.write(inputbytearray, 0, inputbytearray.length);
cstream.flushfinalblock();
return convert.tobase64string(mstream.toarray());
}catch
}/// /// des加密字串
///
/// 待加密的字串
///
public static string encryptdes(string encryptstring)
/// /// des解密字串
///
/// 待解密的字串
/// 解密金鑰,要求8位
///
public static string decryptdes(string decryptstring, string key)
;byte rgbkey = encoding.utf8.getbytes(key);
byte rgbiv = keys;
byte inputbytearray = convert.frombase64string(decryptstring);
descryptoserviceprovider dcsp = new descryptoserviceprovider();
memorystream mstream = new memorystream();
cryptostream cstream = new cryptostream(mstream, dcsp.createdecryptor(rgbkey, rgbiv), cryptostreammode.write);
cstream.write(inputbytearray, 0, inputbytearray.length);
cstream.flushfinalblock();
return encoding.utf8.getstring(mstream.toarray());
}catch
}/// /// des解密字串
///
/// 待解密的字串
///
public static string decryptdes(string decryptstring)
#endregion
aes加密:
#region aes加密與解密
/// /// aes加密
///
/// 要加密字串
/// 返回加密後字串
public static string encryptaes(string str,string aeskey)
/// /// aes解密
///
/// 要解密字串
/// 返回解密後字串
public static string decryptaes(string str, string aeskey)
#endregion
AES加解密方式進行加密和解密
public class cryptionaesutilcatch exception e 加密乙個位元組陣列 param 原陣列 byte throws exception return 加密後的陣列 byte public byte encryptionbytedata byte sourced...
加密和解密
public class desc public static string decode string data catch descryptoserviceprovider cryptoprovider new descryptoserviceprovider memorystream ms n...
加密和解密
公鑰密碼體制的核心思想是 加密和解密採用不同的金鑰。這是公鑰密碼體制和傳統對稱密碼體制的最大區別。對於傳統對稱密碼而言,密文的安全性完全依賴於金鑰的保密性,一旦金鑰洩露,將毫無保密性可言。但是公鑰密碼體制徹底改變了這樣狀況,在公鑰密碼體制中,公鑰是公開的,只有私鑰是保密的,知道公鑰和密碼演算法要推測...