以下代码是VB代码,在VB中调用这个加解密模块的代码,不知道在Foxtable中怎么操作,说的有点哆嗦了......
'-----------------------------------------
'Design By DYB
'Description:加密,解密模块,用于加密用户的口令
'Date:上午 11:40 2002/11/12
'-----------------------------------------
Option Explicit
Const strPaiYi As String = "4E5V43"
Private Declare Function Get_ConvertPassword Lib "tws_erp.dll" (ByVal strPwd As String) As Long
Private Declare Function lstrcpyn Lib "kernel32" Alias "lstrcpynA" (ByVal lpString1 As String, ByVal lpString2 As Long, ByVal iMaxLength As Long) As Long
Public Function ConvertToNum3(ByVal strPass As String) As String
'将密码变成密文
On Error GoTo Errorhander
Dim strTmp As String * 35
lstrcpyn strTmp, Get_ConvertPassword(strPass), 35
ConvertToNum3 = VBA.Left(strTmp, Len(strTmp) - 2)
Exit Function
Errorhander:
MsgBox Err.Description
End Function
Public Function ConvertToNum(strPass As String) As String
'将密码变成密文
On Error GoTo Errorhander
Dim strNew As String
Dim strChar As String
Dim strHeader As String
Dim i As Integer
Dim intMax As Integer
Dim dblTemp As Double
Dim strWei As String
For i = 1 To Len(strPass)
strChar = Mid(strPass, i, 1)
strNew = strNew & CStr(Asc(strChar)) & strPaiYi
Next
Randomize
dblTemp = 0.4934831
intMax = Int((26 * dblTemp) + 48)
strHeader = Chr(intMax)
For i = 1 To intMax
dblTemp = dblTemp + 0.022
If dblTemp > 0.99 Then dblTemp = dblTemp - 0.00301
strHeader = strHeader & Chr(Int((26 * dblTemp) + 48))
Next
For i = 1 To Len(strPaiYi)
dblTemp = dblTemp + 0.00216
If dblTemp > 0.98 Then dblTemp = dblTemp - 0.00521
strWei = strWei & Chr(Int((26 * dblTemp) + 48))
Next
ConvertToNum = strHeader & StrReverse(strNew) & strWei
Exit Function
Errorhander:
End Function
Public Function ConvertNumToStr(strNum As String) As String
'将密文还原成密码
On Error GoTo Errorhander
Dim strNew As String
Dim strChar() As String
Dim i As Integer
Dim intMax As Integer
intMax = Asc(VBA.Left(strNum, 1))
strNum = Right(strNum, Len(strNum) - intMax)
strNum = VBA.Left(strNum, Len(strNum) - Len(strPaiYi))
strChar = Split(StrReverse(strNum), strPaiYi)
For i = 0 To UBound(strChar) - 1
strNew = strNew & Chr(strChar(i))
Next
ConvertNumToStr = strNew
Exit Function
Errorhander:
'MsgBox "密文被破坏,无法解密", vbInformation
End Function