zoukankan      html  css  js  c++  java
  • Delphi 使用MD5 比对文件

    使用MD5的方法比对CXimage里图片是否改变:

    Delphi7实现方法:

    uses IdHashMessageDigest 
    
    function TForm1.GetImageMD5(cxImage: TcxImage): string;
    var
      tmpMD5: TIdHashMessageDigest5;
      ms: TMemoryStream;
    begin
      result:='';
      if cxImage.Picture.Graphic=nil then exit;
      tmpMD5:=TIdHashMessageDigest5.Create;
      ms:= TMemoryStream.Create;
      try
        cxImage.Picture.Graphic.SaveToStream(ms);
        result:=tmpMD5.AsHex(tmpMD5.HashValue(ms));
      finally
        tmpMD5.Free;
        ms.Free;
      end;
    end;
    View Code

    Delphi2010实现方法:

     1 uses IdHashMessageDigest
     2 
     3 function GetImageMD5(cxImage: TcxImage): string;
     4 var
     5   tmpMD5: TIdHashMessageDigest5;
     6   ms: TMemoryStream;
     7 begin
     8   result:='';
     9   if cxImage.Picture.Graphic=nil then exit;
    10   tmpMD5:=TIdHashMessageDigest5.Create;
    11   ms:= TMemoryStream.Create;
    12   try
    13     cxImage.Picture.Graphic.SaveToStream(ms);
    14     ms.Position:=0;
    15     result:=tmpMD5.HashStreamAsHex(ms);
    16   finally
    17     tmpMD5.Free;
    18      ms.Free;
    19   end;
    20 end;
    View Code

    参考:http://www.cnblogs.com/jxsoft/archive/2011/08/08/2131436.html

  • 相关阅读:
    JavaOOP对象和封装
    使用socket实现文件复制
    多线程模拟银行取款
    初入多线程示例展示--Runner
    初步学习多线程3
    初步学习多线程2
    初步线程学习1
    守护线程_setDaemon()
    多线程_yield()和sleep()方法比较
    java_多线程_优先级
  • 原文地址:https://www.cnblogs.com/stroll/p/4681539.html
Copyright © 2011-2022 走看看