namespace
encryptdll
else
if(sha1.computehash(encoding.default.getbytes(strkey)).length
<
tdes.key.length)
//初始向量的設定
if(sha1.computehash(encoding.default.getbytes(strnameplusbirthday)).length
>
tdes.iv.length)
else
if(sha1.computehash(encoding.default.getbytes(strnameplusbirthday)).length
<
tdes.iv.length)
byte
encryptbuffer
=encoding.default.getbytes(strmsg);
memorystream streammemory
=new
memorystream();
cryptostream crystream
=null;//
加密流byte
readbuffer;
//用來接受加密資料
trycatch
finally
return
readbuffer;
}#endregion
#region
對稱解密**
//////
對稱解密方法
//////
需要解密的資料
///解密key
///解密向量
///解密後的資料
public
static
string
symmetricdecryptionfunction(
this
byte
bufmsg,
string
key,
string
iv)else
if(sha1.computehash(encoding.default.getbytes(strkey)).length
<
tdes.key.length)
//初始向量的設定
if(sha1.computehash(encoding.default.getbytes(strnameplusbirthday)).length
>
tdes.iv.length)
else
if(sha1.computehash(encoding.default.getbytes(strnameplusbirthday)).length
<
tdes.iv.length)
byte
readbuffer
=bufmsg;
memorystream streamread
=new
memorystream(readbuffer);
cryptostream decrystream
=null
;byte
bufferreader;
tryfinally
string
decrystring
=encoding.default.getstring(bufferreader);
return
decrystring;
}#endregion
}#endregion
}
對稱加密解密類
using system using system.collections.generic using system.web using system.security.cryptography using system.text using system.io using system.web.u...
加密解密幫助類(對稱加密)
1 對稱加密幫助類 2public static class cryptohelper3 22 provider.key encoding.utf8.getbytes key 2324 encryptor provider.createencryptor 25 建立明文流 26byte clearb...
對稱加密 解密
加密 public static class encrypting 使用對稱演算法加密 public static string symmetricencrypts string str 如需指定加密演算法,可在create 引數中指定字串 create 方法中的引數可以是 des rc2 syst...