UTF8 이후 MD5

2827 단어 utf8
  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;

좋은 웹페이지 즐겨찾기