VB 加密解密程序
2006-05-18 18:47
323 查看
' 加密解密程序
'
'
'---------------------------------------------------------------------------------------------------------------
Function cipher(stext As String) '密码加密程序
Const min_asc = 32
Const max_asc = 126
Const num_asc = max_asc - min_asc + 1
Dim offset As Long
Dim strlen As Integer
Dim i As Integer
Dim ch As Integer
Dim ptext As String
offset = 123
Rnd (-1)
Randomize (offset)
strlen = Len(stext)
For i = 1 To strlen
ch = Asc(Mid(stext, i, 1))
If ch >= min_asc And ch <= max_asc Then
ch = ch - min_asc
offset = Int((num_asc + 1) * Rnd())
ch = ((ch + offset) Mod num_asc)
ch = ch + min_asc
ptext = ptext & Chr(ch)
End If
Next i
cipher = ptext
End Function
Function decipher(stext As String) '密码解密程序
Const min_asc = 32 '最小ASCII码
Const max_asc = 126 '最大ASCII码 字符
Const num_asc = max_asc - min_asc + 1
Dim offset As Long
Dim strlen As Integer
Dim i As Integer
Dim ch As Integer
Dim ptext As String
offset = 123
Rnd (-1)
Randomize (offset)
strlen = Len(stext)
For i = 1 To strlen
ch = Asc(Mid(stext, i, 1)) '取字母转变成ASCII码
If ch >= min_asc And ch <= max_asc Then
ch = ch - min_asc
offset = Int((num_asc + 1) * Rnd())
ch = ((ch - offset) Mod num_asc)
If ch < 0 Then
ch = ch + num_asc
End If
ch = ch + min_asc
ptext = ptext & Chr(ch)
End If
Next i
decipher = ptext
End Function
'
'
'---------------------------------------------------------------------------------------------------------------
Function cipher(stext As String) '密码加密程序
Const min_asc = 32
Const max_asc = 126
Const num_asc = max_asc - min_asc + 1
Dim offset As Long
Dim strlen As Integer
Dim i As Integer
Dim ch As Integer
Dim ptext As String
offset = 123
Rnd (-1)
Randomize (offset)
strlen = Len(stext)
For i = 1 To strlen
ch = Asc(Mid(stext, i, 1))
If ch >= min_asc And ch <= max_asc Then
ch = ch - min_asc
offset = Int((num_asc + 1) * Rnd())
ch = ((ch + offset) Mod num_asc)
ch = ch + min_asc
ptext = ptext & Chr(ch)
End If
Next i
cipher = ptext
End Function
Function decipher(stext As String) '密码解密程序
Const min_asc = 32 '最小ASCII码
Const max_asc = 126 '最大ASCII码 字符
Const num_asc = max_asc - min_asc + 1
Dim offset As Long
Dim strlen As Integer
Dim i As Integer
Dim ch As Integer
Dim ptext As String
offset = 123
Rnd (-1)
Randomize (offset)
strlen = Len(stext)
For i = 1 To strlen
ch = Asc(Mid(stext, i, 1)) '取字母转变成ASCII码
If ch >= min_asc And ch <= max_asc Then
ch = ch - min_asc
offset = Int((num_asc + 1) * Rnd())
ch = ((ch - offset) Mod num_asc)
If ch < 0 Then
ch = ch + num_asc
End If
ch = ch + min_asc
ptext = ptext & Chr(ch)
End If
Next i
decipher = ptext
End Function
相关文章推荐
- OD学习笔记10:一个VB程序的加密和解密思路
- VB.NET 的 DES 加密与解密(转载于nofort博客)
- Maxtocode对.Net程序加密的原理及解密探讨五(元数据还原以及IL解码的改进)
- 02-06加密与解密_设计程序
- 微信小程序-AES加密解密
- MaxtoCode对.Net程序加密的原理及解密探讨
- 实验三 结对项目 加密与解密程序
- 破解zend加密php程序工具 解密成功
- 采用密码加密的javascript字符串加密、解密程序
- ASP程序加密解密方法全面解析
- [VB.NET源码]45_加密解密文件
- 一个用java写的加密解密程序
- 文本加密解密示例小程序java源码
- ASP程序加密解密方法全面解析
- MaxtoCode对.Net程序加密的原理及解密探讨三(实例解密)
- 采用密码加密的javascript字符串加密、解密程序
- 『原创』c#实现文件加密、解密及文件拖拽至程序图标直接打开
- base64高级加密解密程序
- php自定义加密与解密程序实例
- php自定加密与解密程序