ajax客户端与服务端传输字符串

需要加密/解密。目前有两种方案:

1.URL Encode
client:
1)Encode:
escape(utf16to8(strValue));

2)Decode:
utf8to16(unescape(strValue));


Server:
1)Encode:
Server.UrlEncode(strValue);

2)Decode:
Server.UrlDecode(strValue);



2.BASE64
client:
1)Encode:
base64decode(utf16to8(strValue));

2)Decode:
utf8to16(base64decode(strValue));

Server:
1)Encode:
byte[] ary=Encoding.UTF8.GetBytes(strValue);
string str=Convert.ToBase64String(ary);

2)Decode:
byte[] ary=Convert.FromBase64String(strValue);
string str=Encoding.UTF8.GetString(ary);

你可能感兴趣的:(Ajax)