convert string of bytes to byte array
There're at least four different ways doing this conversion. Encoding's GetString. , but you won't be able to get the original bytes back if those bytes have non-ASCII characters. BitConverter.ToString. The output is a - delimited string, but there's no .NET built-in method to convert the string back to byte array. Convert.ToBase64String. You can easily convert the output string back to byte array by using Convert.FromBase64String. Note: The output string could contain '+', '/' and '='. If you want to use the string in a URL, you need to explicitly encode it. HttpServerUtility.UrlTokenEncode. You can easily convert the output string back to byte array by using HttpServerUtility.UrlTokenDecode.