<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>凉风集 &#187; Delphi</title>
	<atom:link href="http://www.lifangjin.com/archives/tag/delphi/feed" rel="self" type="application/rss+xml" />
	<link>http://www.lifangjin.com</link>
	<description>李方进的个人BLOG</description>
	<lastBuildDate>Sun, 05 Feb 2012 15:36:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>二三事</title>
		<link>http://www.lifangjin.com/archives/581</link>
		<comments>http://www.lifangjin.com/archives/581#comments</comments>
		<pubDate>Mon, 10 Nov 2008 03:38:33 +0000</pubDate>
		<dc:creator>李 方进</dc:creator>
				<category><![CDATA[生活感悟]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[MacBook]]></category>

		<guid isPermaLink="false">http://www.lifangjin.com/?p=581</guid>
		<description><![CDATA[1.上周四晚应老婆科室的师兄邀请去解决一个代码问题。很奇怪是吧？为何医学专业的博士生需要自己写代码？一开始我也很疑惑，后来到了实验室以后我才知道，原来他们用的有一种实验仪器是电脑控制的，仪器厂在制造实验仪器的时候，还会开发一套用于电脑控制的软件，这个软件应该是delphi开发的，内置一个简单的脚本解析引擎，使用这个仪器的人只要写一些简单的脚本去实现实验操作步骤。由于该“师兄”完全没有编程经验，自己写的脚本都是根据范例自己改的，出现了没有按照预期步骤执行的效果，听老婆说我会编程于是就找我去看看问题出在哪里。脚本语言很简单，大约半小时以后我改了一下，顺便教了教。但是不确定是否改正确了，必须要根据实验步骤等待5小时左右才行确知最后的结果。周五上午老婆给我发了个短信说我改对了，现在实验步骤正常。哈，内心小小的虚荣了一把——咱好歹也给博士生上过一次课了。另外，我觉得似乎这类专注于某一非计算机领域的软件应用存在一定的开发价值，比方说，给这个仪器写一个仿真软件，然后做一个时间加速，这样在这个软件上不用花时间等待就能检验自己写的小脚本是否正确，还能节省其他的成本，比如药物。 2.破财消灾，老婆的MACBOOK进水了，我怀疑是主板烧了，网上查了下，换个主板大约要2000-3000元，有点郁闷。]]></description>
			<content:encoded><![CDATA[<p>1.上周四晚应老婆科室的师兄邀请去解决一个代码问题。很奇怪是吧？为何医学专业的博士生需要自己写代码？一开始我也很疑惑，后来到了实验室以后我才知道，原来他们用的有一种实验仪器是电脑控制的，仪器厂在制造实验仪器的时候，还会开发一套用于电脑控制的软件，这个软件应该是delphi开发的，内置一个简单的脚本解析引擎，使用这个仪器的人只要写一些简单的脚本去实现实验操作步骤。由于该“师兄”完全没有编程经验，自己写的脚本都是根据范例自己改的，出现了没有按照预期步骤执行的效果，听老婆说我会编程于是就找我去看看问题出在哪里。脚本语言很简单，大约半小时以后我改了一下，顺便教了教。但是不确定是否改正确了，必须要根据实验步骤等待5小时左右才行确知最后的结果。周五上午老婆给我发了个短信说我改对了，现在实验步骤正常。哈，内心小小的虚荣了一把——咱好歹也给博士生上过一次课了。另外，我觉得似乎这类专注于某一非计算机领域的软件应用存在一定的开发价值，比方说，给这个仪器写一个仿真软件，然后做一个时间加速，这样在这个软件上不用花时间等待就能检验自己写的小脚本是否正确，还能节省其他的成本，比如药物。</p>
<p>2.破财消灾，老婆的MACBOOK进水了，我怀疑是主板烧了，网上查了下，换个主板大约要2000-3000元，有点郁闷。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lifangjin.com/archives/581/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>尝试在delphi开发过程中使用LUA进行扩展</title>
		<link>http://www.lifangjin.com/archives/351</link>
		<comments>http://www.lifangjin.com/archives/351#comments</comments>
		<pubDate>Wed, 13 Jun 2007 07:27:04 +0000</pubDate>
		<dc:creator>李 方进</dc:creator>
				<category><![CDATA[开发编程]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Lua]]></category>

		<guid isPermaLink="false">http://www.lifangjin.com/?p=351</guid>
		<description><![CDATA[使用的是lua for delphi扩展，文件共有5个，一个dll，4个pas。 lua版本是5.0.2，可以点击这里下载。 写了一个简单的demo，delphi主程序完成对lua扩展的加载，同时对用户输入的日期以及当前日期进行比较，lua文件完成对比较结果的文字化输出。代码如下： test.lua function dayinfo(num) local strdayinfo; if (num==0) then strdayinfo=&#34;今天&#34;; elseif (num&#38;gt;0) then strdayinfo=num..&#34;天前&#34;; elseif (num&#38;lt;0) then strdayinfo=math.abs(num)..&#34;天后&#34;; end print(strdayinfo); end delphi主程序 unit Unit1; &#160; interface &#160; uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,DateUtils; &#160; type TForm1 = class(TForm) Label1: TLabel; Button1: TButton; Edit1: TEdit; Memo1: TMemo; [...]]]></description>
			<content:encoded><![CDATA[<p>使用的是lua for delphi扩展，文件共有5个，一个dll，4个pas。<br />
lua版本是5.0.2，可以<a href="http://www.lifangjin.com/wp-content/uploads/2007/06/lua4delphi.zip" title="lua4delphi.zip">点击这里</a>下载。<br />
写了一个简单的demo，delphi主程序完成对lua扩展的加载，同时对用户输入的日期以及当前日期进行比较，lua文件完成对比较结果的文字化输出。代码如下：<br />
test.<a href="http://www.lifangjin.com/archives/tag/lua" class="st_tag internal_tag" rel="tag" title="Posts tagged with Lua">lua</a></p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">function dayinfo(num)</li>
<li>local strdayinfo;</li>
<li>if (num==0) then</li>
<li>strdayinfo=&quot;今天&quot;;</li>
<li>elseif (num&amp;gt;0) then</li>
<li>strdayinfo=num..&quot;天前&quot;;</li>
<li>elseif (num&amp;lt;0) then</li>
<li>strdayinfo=math.abs(num)..&quot;天后&quot;;</li>
<li>end</li>
<li>print(strdayinfo);</li>
<li>end</li></ol></div>
<p><span id="more-351"></span><br />
delphi主程序</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">unit Unit1;</li>
<li>&nbsp;</li>
<li>interface</li>
<li>&nbsp;</li>
<li>uses</li>
<li>Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,</li>
<li>Dialogs, StdCtrls,DateUtils;</li>
<li>&nbsp;</li>
<li>type</li>
<li>TForm1 = class(TForm)</li>
<li>Label1: TLabel;</li>
<li>Button1: TButton;</li>
<li>Edit1: TEdit;</li>
<li>Memo1: TMemo;</li>
<li>procedure FormCreate(Sender: TObject);</li>
<li>procedure Button1Click(Sender: TObject);</li>
<li>private</li>
<li>{ Private declarations }</li>
<li>public</li>
<li>{ Public declarations }</li>
<li>end;</li>
<li>&nbsp;</li>
<li>var</li>
<li>Form1: TForm1;</li>
<li>&nbsp;</li>
<li>implementation</li>
<li>&nbsp;</li>
<li>{$R *.dfm}</li>
<li>uses</li>
<li>lua, lualib, lauxlib, LuaUtils;</li>
<li>&nbsp;</li>
<li>procedure TForm1.FormCreate(Sender: TObject);</li>
<li>begin</li>
<li>Edit1.Text:=datetostr(date());</li>
<li>//Edit1.Text:=inttostr(DayOfTheYear(date()));</li>
<li>end;</li>
<li>&nbsp;</li>
<li>function LuaPrint(L: Plua_State): Integer; cdecl;</li>
<li>var</li>
<li>I, N: Integer;</li>
<li>begin</li>
<li>//LuaShowStack(L, 'fobOp:LuaPrint ?n?');</li>
<li>&nbsp;</li>
<li>N := lua_gettop(L);</li>
<li>for I := 1 to N do</li>
<li>Form1.Label1.caption:=lua_tostring(L, I);</li>
<li>Result := 0;</li>
<li>end;</li>
<li>&nbsp;</li>
<li>procedure TForm1.Button1Click(Sender: TObject);</li>
<li>var</li>
<li>L: Plua_State;</li>
<li>begin</li>
<li>// Label1.Caption:= inttostr(DayOfTheYear(date())-DayOfTheYear(strtodate(Edit1.Text)));</li>
<li>&nbsp;</li>
<li>Memo1.Lines.LoadFromFile('test.lua');</li>
<li>Memo1.Lines.Add('dayinfo('+inttostr(DayOfTheYear(date())-DayOfTheYear(strtodate(Edit1.Text)))+')');</li>
<li>L := lua_open;</li>
<li>try</li>
<li>luaopen_math(L);</li>
<li>LuaRegister(L, 'print', LuaPrint);</li>
<li>LuaLoadBuffer(L, Memo1.Text, 'code');</li>
<li>LuaPCall(L, 0, 0, 0);</li>
<li>finally</li>
<li>lua_close(L);</li>
<li>end;</li>
<li>end;</li>
<li>end.</li></ol></div>
<p>经测试成功，程序会在label1中根据用户输入的日期来输出是今天，还是n天前或者n天后。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lifangjin.com/archives/351/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>delphi和c#的MD5加密(32位)</title>
		<link>http://www.lifangjin.com/archives/91</link>
		<comments>http://www.lifangjin.com/archives/91#comments</comments>
		<pubDate>Fri, 24 Mar 2006 05:10:55 +0000</pubDate>
		<dc:creator>李 方进</dc:creator>
				<category><![CDATA[开发编程]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[MD5]]></category>

		<guid isPermaLink="false">http://www.lifangjin.com/?p=91</guid>
		<description><![CDATA[c#代码: System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(string ,&#8221;MD5&#8243;); delphi代码: {*_* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Author:       Fran鏾is PIETTE. Based on work given by Louis S. Berman from               BrainTree Ltd, lsb@braintree.com Description:  MD5 is an implmentation for the MD5 Message-Digest Algorithm               as described in RFC-1321 Creation:     October 11, 1997 Version:      1.03 EMail:        http://users.swing.be/francois.piette  francois.piette@swing.be               http://www.rtfm.be/fpiette             francois.piette@rtfm.be               francois.piette@pophost.eunet.be Support:      Use the mailing list twsocket@rtfm.be See website for details. Legal issues: Copyright (C) 1997, 1998 by Fran鏾is PIETTE               Rue de Grady 24, 4053 Embourg, Belgium. Fax: +32-4-365.74.56               &#60;francois.piette@pophost.eunet.be&#62;               This software is provided &#8217;as-is&#8217;, without any express or               implied warranty.  In no event will the author be held liable               for any  damages arising from the use of this software.               Permission is granted to anyone to use this software for any               purpose, including commercial applications, and to alter it               and redistribute it freely, subject to the following               restrictions:               1. The origin of this software must not be misrepresented,                  you must not claim that you wrote the original software.                  If you use this software in a product, an acknowledgment                  in the product documentation would be appreciated but is                  not required.               2. Altered source versions must be plainly marked as such, and                  must not be misrepresented as being the original software.               3. This notice may not be removed or altered from any source                  distribution.               4. You must register this software by sending a picture postcard                  to the author. Use a nice stamp and mention your name, street                  address, EMail address and any comment you like to say. Updates: Oct 26, 1997 Changed MD5Final form function to procedure to be compatible              with C++Builder. Jul 09, 1998 V1.01 Adapted for Delphi 4 Aug 06, 1998 V1.02 Added R- Q- directive Jun 05, 1999 V1.03 Wolfgang Klein found a bug in MD5Update. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *} unit MD5; interface uses     SysUtils; const     MD5Version         = 102;     CopyRight : String = &#8217; MD5 Message-Digest (c) 97-98 F. Piette V1.02 &#8217;; {$Q-} {$R-} type     TMD5Context = record         State: array[0..3] of LongInt; [...]]]></description>
			<content:encoded><![CDATA[<p>c#代码:<br />
System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(string ,&#8221;<a href="http://www.lifangjin.com/archives/tag/md5" class="st_tag internal_tag" rel="tag" title="Posts tagged with MD5">MD5</a>&#8243;);</p>
<p>delphi代码:<br />
{*_* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *</p>
<p>Author:       Fran鏾is PIETTE. Based on work given by Louis S. Berman from<br />
              BrainTree Ltd, lsb@braintree.com<br />
Description:  MD5 is an implmentation for the MD5 Message-Digest Algorithm<br />
              as described in RFC-1321<br />
Creation:     October 11, 1997<br />
Version:      1.03<br />
EMail:        http://users.swing.be/francois.piette  francois.piette@swing.be<br />
              http://www.rtfm.be/fpiette             francois.piette@rtfm.be<br />
              francois.piette@pophost.eunet.be<br />
Support:      Use the mailing list twsocket@rtfm.be See website for details.<br />
Legal issues: Copyright (C) 1997, 1998 by Fran鏾is PIETTE<br />
              Rue de Grady 24, 4053 Embourg, Belgium. Fax: +32-4-365.74.56<br />
              &lt;francois.piette@pophost.eunet.be&gt;</p>
<p>              This software is provided &#8217;as-is&#8217;, without any express or<br />
              implied warranty.  In no event will the author be held liable<br />
              for any  damages arising from the use of this software.</p>
<p>              Permission is granted to anyone to use this software for any<br />
              purpose, including commercial applications, and to alter it<br />
              and redistribute it freely, subject to the following<br />
              restrictions:</p>
<p>              1. The origin of this software must not be misrepresented,<br />
                 you must not claim that you wrote the original software.<br />
                 If you use this software in a product, an acknowledgment<br />
                 in the product documentation would be appreciated but is<br />
                 not required.</p>
<p>              2. Altered source versions must be plainly marked as such, and<br />
                 must not be misrepresented as being the original software.</p>
<p>              3. This notice may not be removed or altered from any source<br />
                 distribution.</p>
<p>              4. You must register this software by sending a picture postcard<br />
                 to the author. Use a nice stamp and mention your name, street<br />
                 address, EMail address and any comment you like to say.</p>
<p>Updates:<br />
Oct 26, 1997 Changed MD5Final form function to procedure to be compatible<br />
             with C++Builder.<br />
Jul 09, 1998 V1.01 Adapted for <a href="http://www.lifangjin.com/archives/tag/delphi" class="st_tag internal_tag" rel="tag" title="Posts tagged with Delphi">Delphi</a> 4<br />
Aug 06, 1998 V1.02 Added R- Q- directive<br />
Jun 05, 1999 V1.03 Wolfgang Klein found a bug in MD5Update.</p>
<p>* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}<br />
unit MD5;</p>
<p>interface</p>
<p>uses<br />
    SysUtils;</p>
<p>const<br />
    MD5Version         = 102;<br />
    CopyRight : String = &#8217; MD5 Message-Digest (c) 97-98 F. Piette V1.02 &#8217;;</p>
<p>{$Q-}<br />
{$R-}</p>
<p>type<br />
    TMD5Context = record<br />
        State: array[0..3] of LongInt;<br />
        Count: array[0..1] of LongInt;<br />
        case Integer of<br />
        0: (BufChar: array[0..63] of Byte);<br />
        1: (BufLong: array[0..15] of LongInt);<br />
    end;<br />
    TMD5Digest = array[0..15] of Char;</p>
<p>procedure MD5Init(var MD5Context: TMD5Context);<br />
procedure MD5Update(var MD5Context: TMD5Context;<br />
                    const Data;<br />
                    Len: Integer);<br />
procedure MD5Transform(var Buf: array of LongInt;<br />
                       const Data: array of LongInt);<br />
procedure MD5UpdateBuffer(var MD5Context: TMD5Context;<br />
                          Buffer: Pointer;<br />
                          BufSize: Integer);<br />
procedure MD5Final(var Digest: TMD5Digest; var MD5Context: TMD5Context);</p>
<p>function GetMD5(Buffer: Pointer; BufSize: Integer): string;<br />
function StrMD5(Buffer : String): string;</p>
<p>implementation</p>
<p>const<br />
    MaxBufSize = 16384;</p>
<p>type<br />
    PMD5Buffer = ^TMD5Buffer;<br />
    TMD5Buffer = array[0..(MaxBufSize - 1)] of Char;</p>
<p>{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}<br />
{ MD5 initialization. Begins an MD5 operation, writing a new context.         }<br />
procedure MD5Init(var MD5Context: TMD5Context);<br />
begin<br />
    FillChar(MD5Context, SizeOf(TMD5Context), #0);<br />
    with MD5Context do begin<br />
        { Load magic initialization constants. }<br />
        State[0] := LongInt($67452301);<br />
        State[1] := LongInt($EFCDAB89);<br />
        State[2] := LongInt($98BADCFE);<br />
        State[3] := LongInt($10325476);<br />
    end<br />
end;</p>
<p>{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}<br />
{ MD5 block update operation. Continues an MD5 message-digest operation,      }<br />
{ processing another message block, and updating the context.                 }<br />
procedure MD5Update(<br />
    var MD5Context: TMD5Context;            { Context                         }<br />
    const Data;                             { Input block                     }<br />
    Len: Integer);                          { Length of input block           }<br />
type<br />
    TByteArray = array[0..0] of Byte;<br />
var<br />
    Index: Word;<br />
    T: LongInt;<br />
begin<br />
    with MD5Context do begin<br />
        T := Count[0];<br />
        Inc(Count[0], LongInt(Len) shl 3);<br />
        if Count[0] &lt; T then<br />
            Inc(Count[1]);<br />
        Inc(Count[1], Len shr 29);<br />
        T := (T shr 3) and $3F;<br />
        Index := 0;<br />
        if T &lt;&gt; 0 then begin<br />
            Index := T;<br />
            T := 64 - T;<br />
            if Len &lt; T then begin<br />
                Move(Data, BufChar[Index], Len);<br />
                Exit;<br />
            end;<br />
            Move(Data, BufChar[Index], T);<br />
            MD5Transform(State, BufLong);<br />
            Dec(Len, T);<br />
            Index := T;  { Wolfgang Klein, 05/06/99 }<br />
        end;<br />
        while Len &gt;= 64 do begin<br />
            Move(TByteArray(Data)[Index], BufChar, 64);<br />
            MD5Transform(State, BufLong);<br />
            Inc(Index, 64);<br />
            Dec(Len, 64);<br />
        end;<br />
        Move(TByteArray(Data)[Index], BufChar, Len);<br />
    end<br />
end;</p>
<p>{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}<br />
{ MD5 finalization. Ends an MD5 message-digest operation, writing the message }<br />
{ digest and zeroizing the context.                                           }<br />
procedure MD5Final(var Digest: TMD5Digest; var MD5Context: TMD5Context);<br />
var<br />
    Cnt : Word;<br />
    P   : Byte;<br />
begin<br />
    with MD5Context do begin<br />
        Cnt := (Count[0] shr 3) and $3F;<br />
        P := Cnt;<br />
        BufChar[P] := $80;<br />
        Inc(P);<br />
        Cnt := 64 - 1 - Cnt;<br />
        if Cnt &lt; 8 then begin<br />
            FillChar(BufChar[P], Cnt, #0);<br />
            MD5Transform(State, BufLong);<br />
            FillChar(BufChar, 56, #0);<br />
        end<br />
        else<br />
            FillChar(BufChar[P], Cnt - 8, #0);<br />
        BufLong[14] := Count[0];<br />
        BufLong[15] := Count[1];<br />
        MD5Transform(State, BufLong);<br />
        Move(State, Digest, 16)<br />
    end;<br />
    FillChar(MD5Context, SizeOf(TMD5Context), #0)<br />
end;</p>
<p>{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}<br />
{ MD5 basic transformation. Transforms state based on block.                  }<br />
procedure MD5Transform(<br />
    var Buf: array of LongInt;<br />
    const Data: array of LongInt);<br />
var<br />
    A, B, C, D: LongInt;</p>
<p>    procedure Round1(var W: LongInt; X, Y, Z, Data: LongInt; S: Byte);<br />
    begin<br />
        Inc(W, (Z xor (X and (Y xor Z))) + Data);<br />
        W := (W shl S) or (W shr (32 - S));<br />
        Inc(W, X)<br />
    end;</p>
<p>    procedure Round2(var W: LongInt; X, Y, Z, Data: LongInt; S: Byte);<br />
    begin<br />
        Inc(W, (Y xor (Z and (X xor Y))) + Data);<br />
        W := (W shl S) or (W shr (32 - S));<br />
        Inc(W, X)<br />
    end;</p>
<p>    procedure Round3(var W: LongInt; X, Y, Z, Data: LongInt; S: Byte);<br />
    begin<br />
        Inc(W, (X xor Y xor Z) + Data);<br />
        W := (W shl S) or (W shr (32 - S));<br />
        Inc(W, X)<br />
    end;</p>
<p>    procedure Round4(var W: LongInt; X, Y, Z, Data: LongInt; S: Byte);<br />
    begin<br />
        Inc(W, (Y xor (X or not Z)) + Data);<br />
        W := (W shl S) or (W shr (32 - S));<br />
        Inc(W, X)<br />
    end;<br />
begin<br />
    A := Buf[0];<br />
    B := Buf[1];<br />
    C := Buf[2];<br />
    D := Buf[3];</p>
<p>    Round1(A, B, C, D, Data[ 0] + LongInt($d76aa478),  7);<br />
    Round1(D, A, B, C, Data[ 1] + LongInt($e8c7b756), 12);<br />
    Round1(C, D, A, B, Data[ 2] + LongInt($242070db), 17);<br />
    Round1(B, C, D, A, Data[ 3] + LongInt($c1bdceee), 22);<br />
    Round1(A, B, C, D, Data[ 4] + LongInt($f57c0faf),  7);<br />
    Round1(D, A, B, C, Data[ 5] + LongInt($4787c62a), 12);<br />
    Round1(C, D, A, B, Data[ 6] + LongInt($a8304613), 17);<br />
    Round1(B, C, D, A, Data[ 7] + LongInt($fd469501), 22);<br />
    Round1(A, B, C, D, Data[ 8] + LongInt($698098d8),  7);<br />
    Round1(D, A, B, C, Data[ 9] + LongInt($8b44f7af), 12);<br />
    Round1(C, D, A, B, Data[10] + LongInt($ffff5bb1), 17);<br />
    Round1(B, C, D, A, Data[11] + LongInt($895cd7be), 22);<br />
    Round1(A, B, C, D, Data[12] + LongInt($6b901122),  7);<br />
    Round1(D, A, B, C, Data[13] + LongInt($fd987193), 12);<br />
    Round1(C, D, A, B, Data[14] + LongInt($a679438e), 17);<br />
    Round1(B, C, D, A, Data[15] + LongInt($49b40821), 22);</p>
<p>    Round2(A, B, C, D, Data[ 1] + LongInt($f61e2562),  5);<br />
    Round2(D, A, B, C, Data[ 6] + LongInt($c040b340),  9);<br />
    Round2(C, D, A, B, Data[11] + LongInt($265e5a51), 14);<br />
    Round2(B, C, D, A, Data[ 0] + LongInt($e9b6c7aa), 20);<br />
    Round2(A, B, C, D, Data[ 5] + LongInt($d62f105d),  5);<br />
    Round2(D, A, B, C, Data[10] + LongInt($02441453),  9);<br />
    Round2(C, D, A, B, Data[15] + LongInt($d8a1e681), 14);<br />
    Round2(B, C, D, A, Data[ 4] + LongInt($e7d3fbc8), 20);<br />
    Round2(A, B, C, D, Data[ 9] + LongInt($21e1cde6),  5);<br />
    Round2(D, A, B, C, Data[14] + LongInt($c33707d6),  9);<br />
    Round2(C, D, A, B, Data[ 3] + LongInt($f4d50d87), 14);<br />
    Round2(B, C, D, A, Data[ 8] + LongInt($455a14ed), 20);<br />
    Round2(A, B, C, D, Data[13] + LongInt($a9e3e905),  5);<br />
    Round2(D, A, B, C, Data[ 2] + LongInt($fcefa3f8),  9);<br />
    Round2(C, D, A, B, Data[ 7] + LongInt($676f02d9), 14);<br />
    Round2(B, C, D, A, Data[12] + LongInt($8d2a4c8a), 20);</p>
<p>    Round3(A, B, C, D, Data[ 5] + LongInt($fffa3942),  4);<br />
    Round3(D, A, B, C, Data[ 8] + LongInt($8771f681), 11);<br />
    Round3(C, D, A, B, Data[11] + LongInt($6d9d6122), 16);<br />
    Round3(B, C, D, A, Data[14] + LongInt($fde5380c), 23);<br />
    Round3(A, B, C, D, Data[ 1] + LongInt($a4beea44),  4);<br />
    Round3(D, A, B, C, Data[ 4] + LongInt($4bdecfa9), 11);<br />
    Round3(C, D, A, B, Data[ 7] + LongInt($f6bb4b60), 16);<br />
    Round3(B, C, D, A, Data[10] + LongInt($bebfbc70), 23);<br />
    Round3(A, B, C, D, Data[13] + LongInt($289b7ec6),  4);<br />
    Round3(D, A, B, C, Data[ 0] + LongInt($eaa127fa), 11);<br />
    Round3(C, D, A, B, Data[ 3] + LongInt($d4ef3085), 16);<br />
    Round3(B, C, D, A, Data[ 6] + LongInt($04881d05), 23);<br />
    Round3(A, B, C, D, Data[ 9] + LongInt($d9d4d039),  4);<br />
    Round3(D, A, B, C, Data[12] + LongInt($e6db99e5), 11);<br />
    Round3(C, D, A, B, Data[15] + LongInt($1fa27cf8), 16);<br />
    Round3(B, C, D, A, Data[ 2] + LongInt($c4ac5665), 23);</p>
<p>    Round4(A, B, C, D, Data[ 0] + LongInt($f4292244),  6);<br />
    Round4(D, A, B, C, Data[ 7] + LongInt($432aff97), 10);<br />
    Round4(C, D, A, B, Data[14] + LongInt($ab9423a7), 15);<br />
    Round4(B, C, D, A, Data[ 5] + LongInt($fc93a039), 21);<br />
    Round4(A, B, C, D, Data[12] + LongInt($655b59c3),  6);<br />
    Round4(D, A, B, C, Data[ 3] + LongInt($8f0ccc92), 10);<br />
    Round4(C, D, A, B, Data[10] + LongInt($ffeff47d), 15);<br />
    Round4(B, C, D, A, Data[ 1] + LongInt($85845dd1), 21);<br />
    Round4(A, B, C, D, Data[ 8] + LongInt($6fa87e4f),  6);<br />
    Round4(D, A, B, C, Data[15] + LongInt($fe2ce6e0), 10);<br />
    Round4(C, D, A, B, Data[ 6] + LongInt($a3014314), 15);<br />
    Round4(B, C, D, A, Data[13] + LongInt($4e0811a1), 21);<br />
    Round4(A, B, C, D, Data[ 4] + LongInt($f7537e82),  6);<br />
    Round4(D, A, B, C, Data[11] + LongInt($bd3af235), 10);<br />
    Round4(C, D, A, B, Data[ 2] + LongInt($2ad7d2bb), 15);<br />
    Round4(B, C, D, A, Data[ 9] + LongInt($eb86d391), 21);</p>
<p>    Inc(Buf[0], A);<br />
    Inc(Buf[1], B);<br />
    Inc(Buf[2], C);<br />
    Inc(Buf[3], D);<br />
end;</p>
<p>{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}<br />
procedure MD5UpdateBuffer(<br />
    var MD5Context: TMD5Context;<br />
    Buffer: Pointer;<br />
    BufSize: Integer);<br />
var<br />
    BufTmp : PMD5Buffer;<br />
    BufPtr : PChar;<br />
    Bytes  : Word;<br />
begin<br />
    New(BufTmp);<br />
    BufPtr := Buffer;<br />
    try<br />
        repeat<br />
            if BufSize &gt; MaxBufSize then<br />
                Bytes := MaxBufSize<br />
            else<br />
                Bytes := BufSize;<br />
            Move(BufPtr^, BufTmp^, Bytes);<br />
            Inc(BufPtr, Bytes);<br />
            Dec(BufSize, Bytes);<br />
            if Bytes &gt; 0 then<br />
                MD5Update(MD5Context, BufTmp^, Bytes);<br />
        until Bytes &lt; MaxBufSize;<br />
    finally<br />
        Dispose(BufTmp);<br />
    end;<br />
end;</p>
<p>{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}<br />
function GetMD5(Buffer: Pointer; BufSize: Integer): string;<br />
var<br />
    I          : Integer;<br />
    MD5Digest  : TMD5Digest;<br />
    MD5Context : TMD5Context;<br />
begin<br />
    for I := 0 to 15 do<br />
        Byte(MD5Digest[I]) := I + 1;<br />
    MD5Init(MD5Context);<br />
    MD5UpdateBuffer(MD5Context, Buffer, BufSize);<br />
    MD5Final(MD5Digest, MD5Context);<br />
    Result := &#8221;;<br />
    for I := 0 to 15 do<br />
        Result := Result + IntToHex(Byte(MD5Digest[I]), 2);<br />
end;</p>
<p>{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}<br />
function StrMD5(Buffer : String): string;<br />
begin<br />
    Result := GetMD5(@Buffer[1], Length(Buffer));<br />
end;</p>
<p>{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}</p>
<p>end.</p>
<p>两种方法32位MD5加密后的结果一样.<br />
&#8212;&#8211;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lifangjin.com/archives/91/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>在delphi中调用webservice</title>
		<link>http://www.lifangjin.com/archives/89</link>
		<comments>http://www.lifangjin.com/archives/89#comments</comments>
		<pubDate>Thu, 02 Mar 2006 02:21:05 +0000</pubDate>
		<dc:creator>李 方进</dc:creator>
				<category><![CDATA[开发编程]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[webservice]]></category>

		<guid isPermaLink="false">http://www.lifangjin.com/?p=89</guid>
		<description><![CDATA[最近的一个项目需要用到这个技术，于是做了一个demo来验证可行性 webservice是用c#写的,提供三个操作:UserLevel 、UserDate、IsLogin 在delphi中使用webservice导入，以下为主程序： procedure TForm1.Btn_OkClick(Sender: TObject); var   strWSDL:string;   Iservice:Service1Soap;   msg:widestring;   strUsername:string;   strPassword:string;   IsLogin:boolean;   UserLevel:integer;   UserDate:string; begin   strWSDL:= Edit1.Text;   HTTPRIO1.WSDLLocation:=strWSDL;   strUsername:=EdtUserName.Text;   strPassword:=EdtPassword.Text;   //HTTPRIO1.HTTPWebNode.Agent := 'Borland SOAP 1.2';   //HTTPRIO1.HTTPWebNode.UseUTF8InHeader := true;   Iservice:= HTTPRIO1 as Service1Soap;   IsLogin:= Iservice.IsLogin(strUsername,strPassword);   if IsLogin=true then   begin   UserLevel:= Iservice.UserLevel(strUsername,strPassword);   UserDate:=  Iservice.UserDate(strUsername,strPassword);   msg:='登陆成功,到期时间为'+UserDate;   if UserLevel=2 then   begin     msg:=msg+'付费用户';     Edt_1.ReadOnly:=false;     Edt_2.ReadOnly:=false;     end   else   begin   msg:=msg+'免费用户';     Edt_1.ReadOnly:=true;     Edt_2.ReadOnly:=false;   end &#160;   end   else   msg:='登陆失败,用户名或者密码错误';   LblMsg.Caption:=msg; end;]]></description>
			<content:encoded><![CDATA[<p>最近的一个项目需要用到这个技术，于是做了一个demo来验证可行性</p>
<p>webservice是用c#写的,提供三个操作:UserLevel 、UserDate、IsLogin</p>
<p>在delphi中使用webservice导入，以下为主程序：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">procedure TForm1.Btn_OkClick(Sender: TObject);</li>
<li>var</li>
<li>  strWSDL:string;</li>
<li>  Iservice:Service1Soap;</li>
<li>  msg:widestring;</li>
<li>  strUsername:string;</li>
<li>  strPassword:string;</li>
<li>  IsLogin:boolean;</li>
<li>  UserLevel:integer;</li>
<li>  UserDate:string;</li>
<li>begin</li>
<li>  strWSDL:= Edit1.Text;</li>
<li>  HTTPRIO1.WSDLLocation:=strWSDL;</li>
<li>  strUsername:=EdtUserName.Text;</li>
<li>  strPassword:=EdtPassword.Text;</li>
<li>  //HTTPRIO1.HTTPWebNode.Agent := 'Borland SOAP 1.2';</li>
<li>  //HTTPRIO1.HTTPWebNode.UseUTF8InHeader := true;</li>
<li>  Iservice:= HTTPRIO1 as Service1Soap;</li>
<li>  IsLogin:= Iservice.IsLogin(strUsername,strPassword);</li>
<li>  if IsLogin=true then</li>
<li>  begin</li>
<li>  UserLevel:= Iservice.UserLevel(strUsername,strPassword);</li>
<li>  UserDate:=  Iservice.UserDate(strUsername,strPassword);</li>
<li>  msg:='登陆成功,到期时间为'+UserDate;</li>
<li>  if UserLevel=2 then</li>
<li>  begin</li>
<li>    msg:=msg+'付费用户';</li>
<li>    Edt_1.ReadOnly:=false;</li>
<li>    Edt_2.ReadOnly:=false;</li>
<li>    end</li>
<li>  else</li>
<li>  begin</li>
<li>  msg:=msg+'免费用户';</li>
<li>    Edt_1.ReadOnly:=true;</li>
<li>    Edt_2.ReadOnly:=false;</li>
<li>  end</li>
<li>&nbsp;</li>
<li>  end</li>
<li>  else</li>
<li>  msg:='登陆失败,用户名或者密码错误';</li>
<li>  LblMsg.Caption:=msg;</li>
<li>end;</li></ol></div>
]]></content:encoded>
			<wfw:commentRss>http://www.lifangjin.com/archives/89/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

