如何用 Delphi 散列一个字符串? [英] How do I hash a string with Delphi?

查看:15
本文介绍了如何用 Delphi 散列一个字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 Delphi 对字符串进行 MD5 哈希?

How do I make an MD5 hash of a string with Delphi?

推荐答案

如果你想要一个 MD5 摘要并且有 Indy 组件已安装,您可以这样做:

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;

Delphi Cryptography Package 支持大多数流行算法:

Most popular algorithms are supported in the Delphi Cryptography Package:

  • 哈弗
  • MD4、MD5
  • RipeMD-128、RipeMD-160
  • SHA-1、SHA-256、SHA-384、SHA-512,
  • 老虎

更新DCPCrypt 现在由 Warren Postma 维护,源代码可以在 这里.

Update DCPCrypt is now maintained by Warren Postma and source can be found here.

这篇关于如何用 Delphi 散列一个字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆