FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How Translate this function in Delphi to FWH
Posts: 603
Joined: Sun May 04, 2008 08:44 PM
How Translate this function in Delphi to FWH
Posted: Thu Oct 22, 2009 02:27 AM
Code (fw): Select all Collapse
Private String geraHash(String Arquivo)
{
 String HashGerado;
 ASCIIEncoding textConverter = newASCIIEncoding();
 MD5CryptoServiceProvider Md5Provider = new MD5CryptoServiceProvider();
 Byte[] ArquivoByte;
 Arquivo = Arquivo.Replace("\r","").Replace("\n","").Replace("\t","");
 ArquivoByte = textConverter.GetBytes(Arquivo);
 ArquivoByte = Md5Provider.ComputerHash(ArquivoByte);
 HashGerado  = ToHexString(ArquivoByte);
 return HashGerado;
}
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: How Translate this function in Delphi to FWH
Posted: Thu Oct 22, 2009 12:21 PM
Lailton,

You can use these functions from [x]Harbour:

PRG functions:

HB_MD5( <cString> ) -> <cMD5>
Calculates RFC 1321 MD5 digest (128-bit checksum)
Parameters:
<cString> - string variable to calculate MD5
Returns:
ASCII hex MD5 digest as 32-byte string
empty string on error

HB_MD5FILE( <cFileName> ) -> <cMD5>
Calculates RFC 1321 MD5 digest (128-bit checksum) of a file contents
(file size is limited by OS limits only)
Parameters:
<cFileName> - file name
Returns:
ASCII hex MD5 digest as 32-byte string
empty string on error

C functions:

void hb_md5( const void * data, ULONG datalen, char * digest )
Parameters:
data - input byte stream
datalen - input stream length
digest - raw (unformatted) MD5 digest buffer
(at least 16 bytes long)

void hb_md5file( HB_FHANDLE hFile, char * digest )
Parameters:
hFile - file handle
digest - raw (unformatted) MD5 digest buffer
(at least 16 bytes long)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: How Translate this function in Delphi to FWH
Posted: Thu Oct 22, 2009 12:28 PM

gracias antonio,
voy provar.

Continue the discussion