以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 如何调用VB的DLL加密解密模块 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=131266) |
-- 作者:fanllys668 -- 发布时间:2019/2/21 17:03:00 -- 如何调用VB的DLL加密解密模块 请教一下,有一个外部用户表,登录的时候用的是一个VB的加解密模块,要在Foxtable中也调用这个模块和这个外部数据表进行自定义用户管理和登陆,这个DLL要怎么调用 以下代码是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 |
-- 作者:有点蓝 -- 发布时间:2019/2/21 17:21:00 -- dll复制到Foxtable的安装目录 |
-- 作者:fanllys668 -- 发布时间:2019/2/21 17:36:00 -- 已放到Foxtable中了,也添加了全局变量,后面就不知道怎么弄了 |
-- 作者:fanllys668 -- 发布时间:2019/2/21 17:38:00 -- 此主题相关图片如下:微信图片_20190221173723.png 直接这样在全局变量里直接建就可以吗
|
-- 作者:有点蓝 -- 发布时间:2019/2/21 20:02:00 -- 全局代码哦,不是全局变量呀:http://www.foxtable.com/webhelp/scr/1937.htm |
-- 作者:fanllys668 -- 发布时间:2019/2/22 14:44:00 -- 可以用这个DLL文件帮我做一个例子吗,加密解密不知道怎么传递过去的,非常感谢 |
-- 作者:有点蓝 -- 发布时间:2019/2/22 15:38:00 -- 全局代码定义好,需要使用的地方这样,比如按钮 dim str as string = ConvertToNum("123456这里是窗口输入的密码"),执行后str就是加密后的结果 dim psw as string = ConvertNumToStr("加密后的结果") ,执行后psw 就是解密后的密码
|