how to save hex string to binary file? : <p>I have a hexString and how can I convert that string into binary and save as a binary file with custom extension? the following is a sample code block which I used to save the string into file.</p>

<pre><code>function HexToString(H: String): String;
var I: Integer;
begin
  Result:= '';
  for I := 1 to length (H) div 2 do
    Result:= Result+Char(StrToInt('$'+Copy(H,(I-1)*2+1,2)));
end;

procedure saveAs();
p, k, c, tmp: HexStr;
begin

   k := StringToHex('mykey');

   //TO DO 
   //I need to convert 'k' into binary and save as new file
end;
</code></pre>
