下面的函数通过使用新的字符来替换原始的每一个字符而对值进行了加密。它先将每个字符转换为其对应的ascii值,再使用一个偏量,然后将(加入偏量的)ascii值转换回字符。这个偏量可以是从1到255之间的任何数。
public function encryptdecrypt(byval value as string) as string
dim strchar as string
dim intcount as integer
dim intascii as integer
dim strencrypted as string
dim intoffset as integer
intoffset = 200
strencrypted = vbnullstring
for intcount = 1 to len(value)
strchar = mid$(value, intcount, 1)
intascii = asc(strchar) xorintoffset
strencrypted = strencrypted & chr(intascii)
next intcount
encryptdecrypt = strencrypted
end function
要使用这个函数,就要对你想要加密的值调用它。它会返回已经过加密的值。要解密一个值,将它传递给这个函数,它就会返回已解密的值。
尽管这个函数对于简单的加密要求来说是很有用的,但是它不应该被用来保护商业上的关键信息。这种加密法的简单性就意味着它能够被很快的破解。
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器