国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設計 > 正文

ASP學習:urldecode 方法補遺

2019-11-18 19:45:54
字體:
來源:轉載
供稿:網友

  asp 里面沒有urldecode函數,好象aspx里有吧,我不太清楚,但asp里面還是用得很多。在網上查找了有別人寫的urldecode函數,但是這個函數有錯誤,而且在一些方面寫得比較難理解。而且有錯誤,當里面有生僻雙字節(jié)文字時就會產生錯誤,如“乄”經urlencoder后為“%81W”,解碼就不能成功。

  其實雙字節(jié)編碼在這里只要把"W"也編成16進制ASC碼就可以。

  知識點:計算機里的cookie也是經過urlencode編碼的,所以urldecode對破解cookie也很有用呵。

  下面是源代碼:

  Function URLDecode(enStr)
  dim deStr
  dim c,i,v
  deStr=""
  for i=1 to len(enStr)
  c=Mid(enStr,i,1)
  if c="%" then
  v=eval("&h"+Mid(enStr,i+1,2))
  if v<128 then
  deStr=deStr&chr(v)
  i=i+2
  else
  if isvalidhex(mid(enstr,i,3)) then
  if isvalidhex(mid(enstr,i+3,3)) then
  v=eval("&h"+Mid(enStr,i+1,2)+Mid(enStr,i+4,2))
  deStr=deStr&chr(v)
  i=i+5
  else
  v=eval("&h"+Mid(enStr,i+1,2)+cstr(hex(asc(Mid(enStr,i+3,1)))))
  deStr=deStr&chr(v)
  i=i+3
  end if
  else
  destr=destr&c
  end if
  end if
  else
  if c="+" then
  deStr=deStr&" "
  else
  deStr=deStr&c
  end if
  end if
  next
  URLDecode=deStr
  end function

  function isvalidhex(str)
  isvalidhex=true
  str=ucase(str)
  if len(str)<>3 then isvalidhex=false:exit function
  if left(str,1)<>"%" then isvalidhex=false:exit function
  c=mid(str,2,1)
  if not (((c>="0") and (c<="9")) or ((c>="A") and (c<="Z"))) then isvalidhex=false:exit function
  c=mid(str,3,1)
  if not (((c>="0") and (c<="9")) or ((c>="A") and (c<="Z"))) then isvalidhex=false:exit function
  end function

  你用此方法解碼“%81W”看看,可以了。

  當然,你還可以玩點小段,使之成為自己的一種字符串加密方式。


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 贡山| 乌审旗| 贡山| 仪陇县| 海原县| 墨竹工卡县| 长子县| 彰化市| 霍山县| 仁怀市| 富蕴县| 和田市| 文水县| 彭州市| 东安县| 卫辉市| 无为县| 四会市| 邵阳市| 洛南县| 兴仁县| 宁武县| 莎车县| 平遥县| 东平县| 将乐县| 扶风县| 新邵县| 汾西县| 三台县| 阳曲县| 墨江| 阿拉善左旗| 鹿泉市| 景德镇市| 新竹县| 保康县| 固安县| 五指山市| 镇雄县| 乾安县|