正文

''XOR加密/解密函数2005-09-25 22:43:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/iamben250/5338.html

分享到:

Option Explicit Private Const strEncryption As String = "Wa7kao19Oh54My256God!" 'XOR加密/解密函数Public Function XOREncryption(strDataIn As String, Optional ByVal strCodeKey As String = "") As String   Dim lonDataPtr As Long   Dim intXORValue1 As Integer   Dim intXORValue2 As Integer   Dim strDataOut As String      If Len(strCodeKey) < 2 Then      strCodeKey = strEncryption   End If      Mid(strCodeKey, 2, 1) = Asc(Chr(1))      For lonDataPtr = 1 To Len(strDataIn)         '第一个XOR的值来自加密字符串      intXORValue1 = Asc(Mid$(strDataIn, lonDataPtr, 1))            '第二个XOR的值来自需要加密的数据(字符串)      intXORValue2 = Asc(Mid$(strCodeKey, ((lonDataPtr Mod Len(strCodeKey)) + 1), 1))            '两个值被XOR后成为一个需要被解密的字符      strDataOut = strDataOut + Chr(intXORValue1 Xor intXORValue2)         Next lonDataPtr      '返回被加密/解密后的数据(是一个字符串)   XOREncryption = strDataOut   End Function

阅读(5546) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册