title: Get UTF-8 bytes from a string in Ruby
body: <p>I have a requirement to "Perform the SHA1 hashing on the UTF-8 bytes of a string".  I'm not sure how to get the UTF-8 bytes out.  Here's an example of what I <em>should</em> get:</p>
  
  <pre><code>original = "http://www.provider.com/article?query=mysearch&amp;abcd&amp;1300459467&amp;our secret key"
  #Perform the sha1 hashing on the UTF-8 bytes of this string, to get ... 
  expected_hashed = "99802fec87b6ef1d45bd07f3053d13 6cfcfbdf0b"
  #... which is a 160 byte fingerprint.
  #You need to then take the 20 byte representation of this string (make sure you're 
  #not just taking the hex string), and base 64 encode that.
  expected_encoded = "mYAv7Ie27x1FvQfzBT0TbPz73ws="
  </code></pre>
  
  <p>It's getting from <code>original</code> to <code>expected_hashed</code> that's giving me the problem: I don't know how to get the UTF-8 bytes out.  I'm doing SHA1 hashing like <code>Digest::SHA1.digest(unhashed_string)</code> and I'm not 100% sure that's appropriate in this instance either. :/  I'm also unsure about what the "20 byte representation of this string" would be.</p>