title: Encoding used in cast from char to byte
body: <p>Take a look at the following C# code:</p>
  <pre><code>byte[] StringToBytesToBeHashed(string to_be_hashed) {
      byte[] to_be_hashed_byte_array = new byte[to_be_hashed.Length];
      int i = 0;
      foreach (char cur_char in to_be_hashed)
      {
          to_be_hashed_byte_array[i++] = (byte)cur_char;
      }
      return to_be_hashed_byte_array;
  }
  </code></pre>
  <p>(function above was extracted from <a href="https://github.com/Softvelum/wmsauth/blob/2de04369ee73fad2ca5ef8d6a67d2e5b136a2811/src/authorize_plugin/UrlProcessor.cs#L78-L84" rel="nofollow noreferrer">these lines of code from the WMSAuth github repo</a>)</p>
  <p>My question is: <strong>What the casting from byte to char does in terms of Encoding?</strong></p>
  <p>I guess it really does nothing in terms of Encoding, but does that mean that the Encoding.Default is the one which is used and so the byte to return will depend on how the framework will encode the underlying string in the specific Operative System?</p>
  <p>And besides, is the char actually bigger than a byte (I'm guessing 2 bytes) and will actually omit the first byte?</p>
  <p>I was thinking in replacing all this by:</p>
  <pre><code>Encoding.UTF8.GetBytes(stringToBeHashed)
  </code></pre>
  <p>What do you think?</p>