在命名空间IdHashSHA,有个函数TidHashSHa1类,用作SHA1加密;
该类的方法Methods有
Constructor:creat
Methods:HashtoHex(const aHash:TidBytes):string;override;
HashBytesAsHex(const aHash:TidBytes):string;该方法将TidBytes类型返回string类;
HashStringAsHex(const AStr:String;ADestEncoding:TidTextEncoding=nil):string
常规SHA1(utf-8)加密:40位SHA1大写
使用HashBytesAsHex代码如下:
function sha1(input:string):string;
var
temp:tidbytes;
begin
with tidhashsha1.create do
try
result:=HashBytesAsHex(TdBytes(Bytesof(input)));
//result:=HashStringAsHex(input);
finally
free;
end;
end;
关于验证自己写的加密函数对错的方法:
百度搜索SHA1加密:
本文介绍了一个SHA1加密函数的实现方法,并提供了具体的代码示例。文章详细解释了如何使用TidHashSHA1类来生成SHA1哈希值,并将其转换为十六进制字符串。此外,还介绍了如何验证自定义加密函数的正确性。
253

被折叠的 条评论
为什么被折叠?



