title: Hash to Hexadecimal Typescript
body: <p>I have this homework but I think the instructions are not clear enough.
  I'm supposed to retrieve a file from a path, that file contains a <code>Hash</code>.</p>
  <p>So I'm using a <code>fetch</code> and <code>JSON</code></p>
  <pre><code>async function ByteToHex(url: string, path: string, throttle){
  try{
      const res = await fetch(path);
      const hash = res.json();
    }
    catch(error){
      console.log(error);
    }
  }
  </code></pre>
  <p>and then it says I gotta apply this function but they never told us how to read or work with hash</p>
  <pre><code>//IMT Hash description: 
  //Length: 8 bytes 
  coefficients := [8]int{ 2, 3, 5, 7, 11, 13, 17, 19 } 
  for each incoming byte, ib: 
    for each byte of the hash, h 
      h[i] = ((h[i-1] + ib) * coefficient[i]) % 255 
      // in the case where i-1 == -1, h[i-1] should be 0.
  </code></pre>
  <p>I'm guessing ib means incoming byte, and h the hash, but I thought the file already gave us the hash, or does a hash contains bytes? or do I have to read only the bytes and after that, I would get a Hash?</p>
  <p>These are the complete instructions<br />
  Write a command-line utility that accepts</p>
  <ol>
  <li>A URL</li>
  <li>A destination path for a file containing a hash</li>
  <li>An optional value for throttling the download<br />
  Given a URL- fetch the file, and apply throttling to the download if requested- without writing the file to disk hash the data using the &quot;IMT Hash&quot; function (described below)- write the hash to the specified destination file in hexadecimal format<br />
  IMT Hash description:
  Length: 8 bytes
  coefficients := [8]int{ 2, 3, 5, 7, 11, 13, 17, 19 }
  for each incoming byte, ib:
  for each byte of the hash, h
  h[i] = ((h[i-1] + ib) * coefficient[i]) % 255
  // in the case where i-1 == -1, h[i-1] should be 0.<br />
  For example, hashing the data:<br />
  data := []byte{12}<br />
  Should result in a hash of: []byte{24, 108, 90, 204, 81, 189, 102, 126}<br />
  When converted to hexadecimal for writing to the output file: 186c5acc51bd667e</li>
  </ol>