探讨对任意一串数字加密的方法

neo40 2004-10-10 09:55:47

看网上对字符加密的代码很多但是没有对数字加密的(当然解密后也是数字)。

不知各位有何高见

异或是最简单的了。
...全文
281 点赞 收藏 10
写回复
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
neo40 2004-10-15
md5加密后是一串乱码,不能返回数字。各位有没有有关数字加密的文章。
回复
guxizhw 2004-10-12
那种是很白痴的加密算法,已知明文可以直接推算出密钥
回复
jam021 2004-10-12
关注,帮你顶!
回复
落伍者 2004-10-12
rsa
md5
或者简单的做个密码表
回复
QWERT520 2004-10-11
UP
回复
ycxf 2004-10-11
和任意一组数字相异或,再异或一次就解密了
回复
还想懒够 2004-10-11
任意一串数字乘以15+2.5:)
回复
lxcc 2004-10-10
一些常见的加密算法的VB版本
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
回复
DerryZhang 2004-10-10
up
回复
tztz520 2004-10-10
'这个可以对数字或字母或汉字加密解密
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 Function

Public 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



回复
发动态
发帖子

1180

社区成员

VB 数据库(包含打印,安装,报表)
申请成为版主
社区公告
暂无公告