I am trying to understand the following:
If I declare 64 bytes as the length of the array (buffer). When I convert to a base 64 string, it says that the length is 88. Should the length not be 64, since I transmit 64 bytes? I might not fully understand how this works. If so, could you explain.
//Generate a cryptographic random number RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); // Create byte array byte[] buffer = new byte[64]; // Get random bytes rng.GetBytes(buffer); // This line gives me 88 as a result. // Shouldn't it give me 64 as declared above? throw new Exception(Convert.ToBase64String(buffer).Length.ToString()); // Return a Base64 string representation of the random number return Convert.ToBase64String(buffer);
source share