views:

4776

answers:

4

What hash algorithms does Delphi support?

+8  A: 

If you want an MD5 digest and have the Indy components installed, you can do this:

uses SysUtils, IdGlobal, IdHash, IdHashMessageDigest;

with TIdHashMessageDigest5.Create do
try
    Result := TIdHash128.AsHex(HashValue('Hello, world'));
finally
    Free;
end;

Most popular algorithms are supported in the Delphi Cryptography Package:

  • Haval
  • MD4, MD5
  • RipeMD-128, RipeMD-160
  • SHA-1, SHA-256, SHA-384, SHA-512,
  • Tiger
devstopfix
Keep in mind the MD5 and 128 bit hash are only in Indy 9. They removed those from Indy 10.
Jim McKeeth
You are talking about IdHashMessageDigest.pas? It's still there, at least in D2006 it's on Indy10 directory.
Fabricio Araujo
A: 

You can also use the WindowsCrypto API with Delphi:

There is a unit in there that wraps all the CryptoAPI. You can also use Lockbox, which is now open source.

In the end you can support pretty much any Hash algorithms with Delphi. The Indy example is probably the closest you will get to natively in Delphi since Indy is included with most versions of Delphi. For the rest you will need to either use a library or write some more code to access the CryptoAPI or implement it yourself.

Jim McKeeth
+3  A: 

As a side note, as of Delphi 2009, all objects in Delphi have a GetHashCode method.

Nick Hodges
+1  A: 

I usually use DCPCrypt2 (Delphi Cryptography Package) from David Barton (City in the Sky).

It is also contains the following Encryption Algorithms:

  • Blowfish
  • Cast 128
  • Cast 256
  • DES, 3DES
  • Ice, Thin Ice, Ice2
  • IDEA
  • Mars
  • Misty1
  • RC2, RC4, RC5, RC6
  • Rijndael (the new AES)
  • Serpent
  • Tea
  • Twofish
Schalk Versteeg