clsEncrypt.cls
资源名称:考勤6.rar [点击查看]
上传用户:djzm888
上传日期:2013-02-15
资源大小:867k
文件大小:3k
源码类别:
其他数据库
开发平台:
Visual Basic
- VERSION 1.0 CLASS
- BEGIN
- MultiUse = -1 'True
- END
- Attribute VB_Name = "clsEncrypt"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = True
- Attribute VB_PredeclaredId = False
- Attribute VB_Exposed = False
- Option Explicit
- '加密函数
- Public Function EncryptPassword(ByVal tempString As String) As String
- Dim stri(11) As Integer
- Dim PassString As String
- Dim i As Long
- Dim modval, quotient As Integer
- For i = 0 To Len(Trim(tempString)) - 1
- stri(i) = CInt(Asc(Mid(tempString, i + 1, 1)))
- Next
- Randomize
- stri(11) = CInt(Rnd(1) * 17371)
- Randomize
- stri(10) = CInt(Rnd(1) * 13791)
- Randomize
- stri(9) = CInt(Rnd(1) * 11111)
- For i = 0 To 2
- stri(0 + i) = (stri(0 + i) - i * 13733) Xor stri(9)
- stri(i + 3) = (stri(i + 3) - i * 13733) Xor stri(10)
- stri(i + 6) = (stri(i + 6) - i * 13733) Xor stri(11)
- Next
- For i = 0 To 11
- quotient = stri(i) And &HFF00
- modval = stri(i) And &HFF
- stri(i) = CInt((modval And &HF0) / &H10)
- modval = modval And &HF
- modval = modval * &H10 + stri(i)
- stri(i) = modval + quotient
- Next
- PassString = stri(0)
- For i = 1 To 11
- PassString = PassString & "#" & CStr(stri(i))
- Next
- EncryptPassword = PassString
- End Function
- '解密函数
- Public Function DisencryptPassword(tempString As String) As String
- Dim i, StartPosition, EndPosition As Integer
- Dim stri(11) As Integer
- Dim freeString As String
- Dim quotient, modval As Integer
- Dim ErrFlag As Boolean
- ErrFlag = False
- StartPosition = 1
- For i = 0 To 10
- EndPosition = InStr(StartPosition, tempString, "#")
- If EndPosition = 0 Or EndPosition = Null Then
- ErrFlag = True
- Exit For
- End If
- stri(i) = CInt(Mid(tempString, StartPosition, EndPosition - StartPosition))
- StartPosition = EndPosition + 1
- Next
- If Not ErrFlag Then
- stri(11) = CInt(Mid(tempString, StartPosition, Len(tempString) + 1 - StartPosition))
- Else
- MsgBox "dkdk", vbCritical + vbSystemModal
- End
- End If
- '------------------------------------------------------------------
- For i = 0 To 11
- quotient = stri(i) And &HFF00
- modval = stri(i) And &HFF
- stri(i) = CInt((modval And &HF0) / &H10)
- modval = modval And &HF
- modval = modval * &H10 + stri(i)
- stri(i) = modval + quotient
- Next
- For i = 0 To 2
- stri(0 + i) = (stri(0 + i) Xor stri(9)) + i * 13733
- stri(i + 3) = (stri(i + 3) Xor stri(10)) + i * 13733
- stri(i + 6) = (stri(i + 6) Xor stri(11)) + i * 13733
- Next
- freeString = Empty
- For i = 0 To 7
- If stri(i) = 0 Then Exit For
- freeString = freeString & Chr(stri(i))
- Next
- DisencryptPassword = Trim(freeString)
- End Function