|
本帖最后由 yiyiyicz 于 2014-8-4 23:00 编辑
在这里首先要感谢“心电感应”坛友,因为他耐心的帮助,我的账号才没有被废掉。许多资料以及和EH中各位坛友的讨论记录,得以保存。在此深表谢意! 关于“加密问题”,对谁来说都难办。以下是针对工程应用。如CAD二次开发,特殊的排程排产,这些都包含了一整套的计算过程。 说到加密,可能最先想到的是软件加密方法。但是,有矛就有盾,有正(加密)就有反(破解)。何况我等草莽出身,那些东西实在是玩不转。 经过摸索,我觉得VBA加密,基本上就是样子货,不堪一击;VB6编译后运行,加密效果比较好。因为反编译后得到是类似汇编语言,不好懂。 当然,我们还可以让反编译出来的东西读起来难上加难。这对我们这些非软件专业的人并不难。 1, 程序中所有的变量都不带物理意义。也就是变量大排行,如A1\A2\…\An。 2, 删除所有的注释 3, 将整套计算逻辑中的关系,用一个关系表来代替(部分计算逻辑关系也可以)。与此同时,用类模块编程来实现运行中运算功能/子例程/函数/事件等跳转。换句话说,就是利用类模块+关系表,实现类似的实现面向对象的“继承”效果。在程序代码中将会出现一系列复杂的对象变量引用及其赋值。下面的简单代码,就是一个实例(是“委托”,也是“回调函数”)。利用上面提到的表,加上委托,可以实现继承,甚至是多层继承\多根继承。
反编译不难做。但是读懂软件内容,恐怕只有和你同专业的才有兴趣。当变量名看不出任何意义;看不到一条注释;一堆对象变量引用\赋值。这些足可以让人就此止步。就算有人玩命去破解,那他至少要付出巨大的时间代价,而且他要能从头到尾猜出你的计算过程和逻辑,这太难了。 下面是一个简单的类模块的实例(如果没有注释也能读懂,请发帖讲一下,这肯定是工程计算高手加VB高手)
- '// 模块 T01Practice 运行Sub Prc()。这段代码写在sheet下也可以
- Sub Prc()
- Dim Reslut As Double, Zx1 As Double, Zx2 As Double, Exp As Double
- Zx1 = 1#
- Zx2 = 10#
- Exp = 0.001
- MainFunc New T01Func1, Reslut, Zx1, Zx2, Exp
- MsgBox "根= " & Reslut
- Reslut = 0
- MainFunc New T01Func2, Reslut, Zx1, Zx2, 0.01
- MsgBox "根= " & Reslut
- End Sub
复制代码
- '// 模块:T01MainFun
- Sub MainFunc(Fun As T01InterFace, Ta As Double, Tb As Double, Tc As Double, Td As Double)
- Dim J As Integer, Jmax As Integer, DX As Double
- Dim Fmid As Double, F As Double, Rtbis As Double
- Dim X1 As Double, X2 As Double, Xmid As Double, Xacc As Double
- Rtbis = Ta
- X1 = Tb
- X2 = Tc
- Xacc = Td
- Jmax = 40
- Fun.BeCallFunc Fmid, X2, 0, 0, 0
- Fun.BeCallFunc F, X1, 0, 0, 0
- If F < 0# Then
- Rtbis = X1
- DX = X2 - X1
- Else
- Rtbis = X2
- DX = X1 - X2
- End If
- For J = 1 To Jmax
- DX = DX * 0.5
- Xmid = Rtbis + DX
- Fun.BeCallFunc Fmid, Xmid, 0, 0, 0
- If Fmid <= 0# Then Ta = Xmid
- If Abs(DX) < Xacc Or Fmid = 0# Then Exit Sub
- Next J
- End Sub
复制代码
- '// 类模块 T01InterFace
- Public Sub BeCallFunc(Tep1 As Double, Tep2 As Double, Tep3 As Double, Tep4 As Double, Tep5 As Double)
- 'modul
- End Sub
复制代码- '// 类模块 T01Func2
- Implements T01InterFace
- Private Sub T01InterFace_BeCallFunc(Tep1 As Double, Tep2 As Double, Tep3 As Double, Tep4 As Double, Tep5 As Double)
- Dim X As Double
- X = Application.WorksheetFunction.Radians(Tep2)
- Tep1 = X + 0.5 * Sin(X) - 8
- End Sub
复制代码- '// 类模块 T01Func1
- Implements T01InterFace
- Private Sub T01InterFace_BeCallFunc(Tep1 As Double, Tep2 As Double, Tep3 As Double, Tep4 As Double, Tep5 As Double)
- Tep1 = 5 * Tep2 * Tep2 - 2 * Tep2 - 6
- End Sub
复制代码
注释见后
|
|