现在的位置: 首页 > 综合 > 正文

asp 的hexEncode 和hexDecode算法

2012年10月15日 ⁄ 综合 ⁄ 共 391字 ⁄ 字号 评论关闭
function hexEncode(str)
	dim strEncoded, i
	strEncoded = ""
	for i = 1 to Len(str)
		strEncoded = strEncoded + "%" + Hex(Asc(Mid(str, i, 1)))
	next
	hexEncode = strEncoded
end function

function hexDecode(str)
	dim strDecoded, i, hexValue
	strDecoded = ""
	for i = 2 to Len(str)
		hexValue = ""
		while Mid(str, i, 1) <> "%" and i <= Len(str)
			hexValue = hexValue + Mid(str, i, 1)
			i = i+1
		wend
		strDecoded = strDecoded + chr(CLng("&h" & hexValue))
	next
	hexDecode = strDecoded
end function

抱歉!评论已关闭.