// There is a space between the nth byte value of the hexadecimal string
Function agetbyteat (hexvalue: string; N: integer): string;
Begin
Result: = copy (hexvalue, (n-1) * 3 + );
End;
// The hexadecimal string starts from n Bytes and has a space between M bytes.
Function agethexsubstr (hexvalue: string; n, m: integer): string;
VaR
I: integer;
Temp: string;
Begin
Temp: = '';
For I: = n to N + M-1 do
Temp: = temp + agetbyteat (hexvalue, I );
Result: = temp;
End;
// Convert a hexadecimal string to a string
Function hexstrtostra (S: string): string;
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;
// Convert a string to a hexadecimal string
Function strtohexstra (S: string): string;
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;
// Add spaces between bytes
Function addspacesep (const S: string): string;
VaR
I: integer;
Begin
Result: = '';
For I: = 1 to length (s) do
Begin
Result: = Result + s [I];
If I mod 2 = 0 then
Result: = Result + '';
End;
End;