聂
聂儿
Unregistered / Unconfirmed
GUEST, unregistred user!
请教各位大虾,我用Delphi做了一个加密/解密程序算法,用dll方式发布,<br>但是不能正常使用。<br>//pass.dll<br>library pass;<br><br>uses<br> shareMem,<br> SysUtils,<br> Classes,<br> En_De in 'En_De.pas';<br>{$R *.RES}<br><br>function EnCrypt(PassStr : PChar) : PChar ; StdCall;<br>var<br> Str : String;<br>//加密<br>begin<br> Str := String(PassStr);<br> Str := EncryptCode(Str);<br> Result := Pchar(str);<br>end;<br><br>function DeCrypt(PassStr : PChar) : PChar ; StdCall;<br>var<br> Str : String;<br>//解密<br>begin<br> Str := String(PassStr);<br> Str := DecryptDode(Str);<br> Result := PChar(Str);<br>end;<br><br>exports<br> EnCrypt,<br> DeCrypt;<br>begin<br>end.<br><br><br>vb程序如下<br>'pass.bas<br>Declare Function EnCrypt Lib "pass.dll" (ByVal Password As<br>String) As String<br>Declare Function DeCrypt Lib "pass.dll" (ByVal Password As <br>String) As String<br><br>'主程序调用<br>dim passstr,secrstr as String<br>passstr = 'xxx'<br>secrstr = Encrypt(passstr)<br>'程序正常运行但是多次执行返回的字符串长度不一样<br><br>passstr = Decrypt(secrstr)<br>'程序正常,但是得不到正确结果<br><br>'EncryptCode(Str)和'DecryptDode(Str)放在delphi程序中没有问,<br>'Encrypt(str)和Decrypt(str)在delphi程序中返回结果与原来密码<br>'位数有不同<br>