title: How to convert string to base64 byte array, would this be valid?
body: <p>I'm trying to write a function that converts a string to a base64 byte array. I've tried with this approach:</p>
  
  <pre><code>public byte[] stringToBase64ByteArray(String input)
  {
      byte[] ret = System.Text.Encoding.Unicode.GetBytes(input);
      string s = Convert.ToBase64String(input);
      ret = System.Text.Encoding.Unicode.GetBytes(s);
      return ret;
  }
  </code></pre>
  
  <p>Would this function produce a valid result (provided that the string is in unicode)?
  Thanks!</p>