function ToUTF8Encode(str: string): string; //将字符串转UTF8编码
  var
    b: Byte;
  begin
    for b in BytesOf(UTF8Encode(str)) do
      Result := Format('%s%%%.2x', [Result, b]);
  end;
  function Encode(const KeyContent, content : string) : string;//加密(密钥, 待加密串)
  var
    md5key : string;
    MyMD5: TIdHashMessageDigest5;
  begin
    md5key := ToUTF8Encode(KeyContent);
    MyMD5 := TIdHashMessageDigest5.Create;
    try
      Result := ToUTF8Encode(Base64EncodeString(MyMD5.HashStringAsHex(content + md5key, enUTF8)));
    finally
      MyMD5.free;
    end;
  end;
const
  Key = 'abc';
var
  Code : string;
begin
  Code := Encode(Key, '123abc');
  ShowMessage(Code);
end;

 

相关文章:

  • 2021-07-30
  • 2021-08-12
  • 2022-12-23
  • 2021-11-12
  • 2021-07-06
  • 2022-02-08
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
  • 2021-10-18
  • 2022-12-23
  • 2021-06-19
相关资源
相似解决方案