看网上对字符加密的代码很多但是没有对数字加密的(当然解密后也是数字)。不知各位有何高见 异或是最简单的了。
解决方案 »
- 随机数+timer控件+图片排序
- 怎样可以使窗体的标题栏隐藏?
- BrowseForFolder在Win98会报错?
- 怎样强制WebBrowser控件不访问cache
- 在线等答案呀
- 在VBA中设置循环连续播放多个ppt文件,在线等,马上揭帖
- VB exe生成器制作成功但要修改下请各位帮下忙
- 怎么去掉窗口的系统菜单
- 请问,在VB中怎样播放GIF格式的动画? Help?
- 求助PPT中的VB抽奖小程序编程
- 请问各位高手,有两个相同的程序,其中一个已经运行。当运行第二次运行时怎样将第一次运行的程序关掉
- 请告诉如何把TrueDBGrid7.0和水晶报表8.0打包的方法(用setup factory6.0打包)
Public Function Encode(ByVal S As String) As String '加密
On Error GoTo acd
If Len(S) = 0 Then Exit Function
Dim Buff() As Byte
Buff = StrConv(S, vbFromUnicode)
Dim i As Long
Dim j As Byte
Dim k As Byte, m As Byte
Dim mstr As String
mstr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"
Dim outs As String
i = UBound(Buff) + 1
outs = Space(2 * i)
Dim Temps As String
For i = 0 To UBound(Buff)
Randomize Time
j = CByte(5 * (Math.Rnd()) + 0) '最大产生的随机数只能是5,不能再大了,再大的话,就要多用一个字节
Buff(i) = Buff(i) Xor j
k = Buff(i) Mod Len(mstr)
m = Buff(i) \ Len(mstr)
m = m * 2 ^ 3 + j
Temps = Mid(mstr, k + 1, 1) + Mid(mstr, m + 1, 1)
Mid(outs, 2 * i + 1, 2) = Temps
Next
Encode = outs
Exit Function
acd:
End FunctionPublic Function Decode(ByVal S As String) As String '解密
On Error GoTo acd
Dim i As Long
Dim j As Byte
Dim k As Byte
Dim m As Byte
Dim mstr As String
mstr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"
Dim t1 As String, t2 As String
Dim Buff() As Byte
Dim n As Long
n = 0
For i = 1 To Len(S) Step 2
t1 = Mid(S, i, 1)
t2 = Mid(S, i + 1, 1)
k = InStr(1, mstr, t1) - 1
m = InStr(1, mstr, t2) - 1
j = m \ 2 ^ 3
m = m - j * 2 ^ 3
ReDim Preserve Buff(n)
Buff(n) = j * Len(mstr) + k
Buff(n) = Buff(n) Xor m
n = n + 1
Next
Decode = StrConv(Buff, vbUnicode)
Exit Function
acd:
Decode = ""
End Function
http://www.china-askpro.com/msg1/qa88.shtml
http://dev.csdn.net/develop/article/8/8353.shtm
http://www.itonline.gd.cn/ittech/list.asp?id=69
http://dev.csdn.net/develop/article/8/8356.shtm
md5
或者简单的做个密码表