url中引數加密

2021-07-24 05:56:51 字數 1306 閱讀 2314

最近在做url帶引數跳轉頁面,發現url位址列會顯示請求的引數,用的是ajax中的post方式,但是貌似沒有自動進行加密,這裡找到乙個解決方案,可以對url中的引數進行加密,在從url中獲取引數時直接解密即可。具體實現方式如下:

實現加密方法:

var c = "house_id="+house_id+"&customer_id="+customer_id+"&house_address="+house_address;

var d = encodeuricomponent(c);

var urlopen = "addorder.html?"+d;

實現解密的函式如下:

//格式化url中的引數

function parsequerystring(url){

var arr;

var name,value;

var url = decodeuricomponent(url);

var str = url.split("?")[1]; //通過?得到乙個陣列,取?後面的引數

var items = str.split("&"); //分割成陣列

for(var i=0; i

var urlpara = new parsequerystring(window.location.search);

var customer_id = urlpara.customer_id;

知識拓展:

window.location.search: 獲得url中?後的字串

encodeuricomponent: 對字串進行加密

decodeuricomponent: 對字串進行解密

split:

split() 方法用於把乙個字串分割成字串陣列。

stringobject.split(separator,howmany)
引數

描述separator

必需。字串或正規表示式,從該引數指定的地方分割 stringobject。

howmany

可選。該引數可指定返回的陣列的最大長度。如果設定了該引數,返回的子串不會多於這個引數指定的陣列。如果沒有設定該引數,整個字串都會被分割,不考慮它的長度。

輸出:

how,are,you,doing,today?

h,o,w, ,a,r,e, ,y,o,u, ,d,o,i,n,g, ,t,o,d,a,y,?

how,are,you

URL引數加密專用

url引數加密專用 region 加密 private static byte key private static byte iv new byte 加密 public static string urlencrypt string strtoencrypt 加密 要加密的字串 金鑰 加密後的字串...

URL傳輸引數加密解密

最近做乙個論壇入口時要實現帳號和密碼不在ie位址列出現而做的 index.aspx.cs 加密處理 byte iv64 byte bykey64 public string encrypt string strtext catch exception ex private void btnlogin...

檔案加密解密 URl引數加密解密

sliverlight 加密解密 public static class encryption endregion region silverlight密碼解密 解密資料 加密後的字串 加密前的字串 public static string decrypt string input endregio...