在dnn中有这么一段函数(globals.vb中):
public function cloaktext()function cloaktext(byval personalinfo as string) as string
if not personalinfo is nothing then
dim sb as new stringbuilder
convert to ascii character codes,将字符串转换成ascii编码字符串形式
sb.remove(0, sb.length)
dim stringlength as integer = personalinfo.length - 1
for i as integer = 0 to stringlength
sb.append(asc(personalinfo.substring(i, 1)).tostring)
if i < stringlength then
sb.append(",")
end if
next
build script block
dim sbscript as new stringbuilder
sbscript.append(vbcrlf & "<script language=""javascript"">" & vbcrlf)
sbscript.append("<!-- " & vbcrlf)
fromcharcode 方法:从一些 unicode 字符值中返回一个字符串。
sbscript.append(" document.write(string.fromcharcode(" & sb.tostring & "))" & vbcrlf)
sbscript.append("// -->" & vbcrlf)
sbscript.append("</script>" & vbcrlf)
return sbscript.tostring
else
return null.nullstring
end if
end function
该段代码先将需要加密的信息转换成ascii编码字符串形式,然后用javascript中的document.write方法写到页面。
我测试了以下效果,还不错。大家也可以试试。
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title>测试信息加密</title>
</head>
<body>
可以被提取的链接:<a href="mailto:aaa@163.com">aaa@163.com</a><br>
不能被提取的链接:
<script language="javascript">
<!--
document.write(string.fromcharcode(60,97,32,104,114,101,102,61,34,109,97,105,108,116,111,58,120,120,120,64,116,111,109,
46,99,111,109,34,62,120,120,120,64,116,111,109,46,99,111,109,60,47,97,62))
// -->
</script>
</body>
</html>
如果大家有兴趣,还可以用更加复杂的方法来进行加密,一句话:再也不能让人轻易获取信息了!
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!


