Function StrToHexStr(Const S: String): String; //字符串转换成16进制字符串(方法一) Var I: Integer; Begin For I := 1 To Length(S) Do Begin If I = 1 Then Result := IntToHex(Ord(S[1]), 2) Else Result := Result + ' ' + IntToHex(Ord(S[I]), 2); End; End; function strToHexStr(str:string):string; //字符串转换成16进制字符串(方法二) var c:char; ss:string; begin while str<>'' do begin c:=str[1]; ss:=ss+format('%0x',[ord(c)]); delete(str,1,1); end; strtohexStr:= ss; end; Function HexStrToStr(Const S: String): String; //16进制字符串转换成字符串 Var t: Integer; ts: String; M, Code: Integer; Begin t := 1; Result := ''; While t <= Length(S) Do Begin While (t <= Length(S)) And (Not (S[t] In ['0'..'9', 'A'..'F', 'a'..'f'])) Do Inc(t); If (t + 1 > Length(S)) Or (Not (S[t + 1] In ['0'..'9', 'A'..'F', 'a'..'f'])) Then ts := '$' + S[t] Else ts := '$' + S[t] + S[t + 1]; Val(ts, M, Code); If Code = 0 Then Result := Result + Chr(M); Inc(t, 2); End; End;