Can someone tell me why the following code intermittently throws an exception ? I am running Vista Ultimate 32 bit and VS2010 .NET4
byte[] saltBytes = new byte[32];
RNGCryptoServiceProvider.Create().GetBytes(saltBytes);
string salt = System.Text.UnicodeEncoding.Unicode.GetString(saltBytes);
byte[] saltBytes2 = System.Text.UnicodeEncoding.Unicode.GetBytes(salt);
int i = 0;
foreach(byte b in saltBytes)
{
if (saltBytes[i] != saltBytes2[i])
{
throw new Exception();
}
i++;
}