Your library does not support Unicode. Just passing it to AnsiString will not be enough, because it probably uses internal strings to store data.
You can try updating this library, waiting for the author to update it, or just use the MessageDigest_5.pas that comes with Delphi 2009. It is in the original \ Win32 \ soap \ wsdlimporter which you will need to either add to your path or explicitly enable into the project.
Here is an example of the code using it in Delphi 2009:
uses Types, MessageDigest_5; procedure TForm16.Edit1Change(Sender: TObject); var MD5: IMD5; begin MD5 := GetMD5; MD5.Init; MD5.Update(TByteDynArray(RawByteString(Edit1.Text)), Length(Edit1.Text)); Edit2.Text := LowerCase(MD5.AsString); end;
And you are in business:
MD5 (123456) = e10adc3949ba59abbe56e057f20f883e
You can wrap it with a simple function call if you want. It is important that before you make TByteDynArray , before casting RawByteString , because when you click RawByteString, all the extra Unicode characters. If editing contains Unicode characters, you may get bad data.
Keep in mind that GetMD5 returns an interface, so a link is calculated, etc.
Merry Christmas!
Jim mckeeth
source share