delphi和.js文件问题

来源:百度知道 编辑:UC知道 时间:2024/06/20 15:57:33
我的一个delphi程序需要md5加密。md5加密程序我会写,但是我写的那个程序需要用到他特定的md5密,我通过他网站的js文件获得了他的MD5信息,但是我不会转换成delphi的,JS文件内容如下,请帮我转成delphi用的谢谢
function rhex(num)
{
str = "";
for(j = 0; j <= 3; j++)
str += hex_chr.charAt((num >> (j * 8 + 4)) & 0x0F) +
hex_chr.charAt((num >> (j * 8)) & 0x0F);
return str;
}
function str2blks_MD5(str)
{
nblk = ((str.length + 8) >> 6) + 1;
blks = new Array(nblk * 16);
for(i = 0; i < nblk * 16; i++) blks[i] = 0;
for(i = 0; i < str.length; i++)
blks[i >> 2] |= str.charCodeAt(i) << ((i % 4) * 8);
blks[i >> 2] |= 0x80 << ((i % 4) * 8);
blks[nblk * 16 - 2] = str.length * 8;
return blks;
}
function add(x, y)
{
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
function rol(num, cnt)
{<

留下你的邮箱,,把源码发给你,太长了,写不上去!

不妨换一种方法:
function ExecScript(Code,Lang,Func:string):string;
var//JavaScript VBScript
script:OleVariant;
begin
script:=CreateOleObject('ScriptControl');
script.Language:=Lang;
script.AddCode(Code);
Result:=script.Eval(Func);
end;
procedure TForm1.Button1Click(Sender:TObject);
begin
MessageDlg(ExecScript(Memo1.Text,'JavaScript','MD5(''Delphi'')'),mtWarning, [mbOK],0);
end;