加密解密Url的類

2021-04-13 06:42:33 字數 1999 閱讀 1140

string _querystringkey = "abcdefgh"; //url傳輸引數加密key

string _passwordkey = "hgfedcba";//password加密key

#region 公共方法

///

/// 加密url傳輸的字串

///

///

///

public string encryptquerystring(string querystring)

///

/// 解密url傳輸的字串

///

///

///

public string decryptquerystring(string querystring)

///

/// 加密帳號口令

///

///

///

private string encryptpassword(string password)

///

/// 解密帳號口令

///

///

///

private string decryptpassword(string password)

#endregion

#region 加密過程

///

/// dec 加密過程

///

///

///

///

private string encrypt(string ptoencrypt, string skey)

des.key = asciiencoding.ascii.getbytes(skey);//建立加密物件的金鑰和偏移量,此值重要,不能修改

des.iv = asciiencoding.ascii.getbytes(skey);

memorystream ms = new memorystream();

cryptostream cs = new cryptostream(ms, des.createdecryptor(), cryptostreammode.write);

cs.write(inputbytearray, 0, inputbytearray.length);

cs.flushfinalblock();

stringbuilder ret = new stringbuilder();//建立stringbuilder物件,createdecrypt使用的是流物件,必須把解密後的文字變成流物件

return system.text.encoding.default.getstring(ms.toarray());

}#endregion

#region 匹配過程

///

/// 檢查己加密的字串是否與原文相同

///

///

///

///

///

private bool validatestring(string enstring, string fostring, int mode)

else

case 2:

if (decrypt(enstring, _passwordkey) == fostring.tostring())

else}}

#endregion}} 

加密解密Url的類

using system using system.security.cryptography using system.io using system.text namespace netbesttone.baseclass string querystringkey abcdefgh url傳輸...

url加密解密

js對文字進行編碼涉及3個函式 escape,encodeuri,encodeuricomponent,相應3個解碼函式 unescape,decodeuri,decodeuricomponent 1 傳遞引數時需要使用encodeuricomponent,這樣組合的url才不會被 等特殊字元截斷。...

寫了個加密解密Url的類

usingsystem usingsystem.security.cryptography usingsystem.io usingsystem.text namespacenetbesttone.baseclass string querystringkey abcdefgh url傳輸引數加密k...