DELPHI sha1 汉字
function sha1(input: string): string; begin with Tidhashsha1.Create do try Result := HashBytesAsHex(TidBytes(Bytesof(input))); finally free; end; end;
针对 sha1签名,之前没有涉及中文字符,一切正常,加入汉字后,签名错误,需要使用下面方法
function sha1(input: string): string; begin with Tidhashsha1.Create do try //Result := HashBytesAsHex(TidBytes(Bytesof(input))); Result := HashStringAsHex(input,IndyTextEncoding_UTF8); finally free; end; end;
浙公网安备 33010602011771号