How do I make an MD5 hash of a string with Delphi?
相关问题
- Is there a Delphi 5 component that can handle .png
- Is there a way to install Delphi 2010 on Windows 2
- facebook error invalid key hash for some devices
- Is TWebBrowser dependant on IE version?
- iOS objective-c object: When to use release and wh
相关文章
- Working with hmacsha256 in windows store app
- Bcrypt vs Hash in laravel
- Best way to implement MVVM bindings (View <-> V
- Windows EventLog: How fast are operations with it?
- How to force Delphi compiler to display all hints
- Coloring cell background on firemonkey stringgrid
- Decrypting EnvelopedCms with non-default Algorithm
- HelpInsight documentation in Delphi 2007
If you want an MD5 digest and have the Indy components installed, you can do this:
Most popular algorithms are supported in the Delphi Cryptography Package:
Update
DCPCrypt
is now maintained by Warren Postma and source can be found here.This is a modification of devstopfix's answer which was accepted.
In current Indy version you can hash strings and streams more easily. Example:
Use
HashString
,HashStringAsHex
,HashBytes
,HashBytesAsHex
,HashStream
,HashStreamAsHex
. The advantage is that you can also specify a text encodingIf all you want to do is use a dictionary, and you're not looking for security then:
In Delphi 2009 and higher, hash values for strings can be created with
BobJenkinsHash
(Value, Length(Value) * SizeOf(Value), 0)
where Value is a string.
http://docwiki.embarcadero.com/VCL/en/Generics.Defaults.BobJenkinsHash
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.
I usually use DCPCrypt2 (Delphi Cryptography Package) from David Barton (City in the Sky).
It is also contains the following Encryption Algorithms:
Update
DCPCrypt
is now maintained by Warren Postma and source can be found here.Spring For Delphi project - http://www.spring4d.org - has implementation for a number of SHAxxx hashes, MD5 hash, and also number of CRC functions