I'm writing an authentication system with sign-up and all. The passwords are hashed with a salt. I've run into a problem where the implementation I'm using operates with the salt and the final hash being byte arrays. I cannot turn this back into regular human-readable string that I can store in SQL and I've tried almost all the Encodings in the Encoding class when printing to the console..
Any help would be much appreciated. Am I just missing something very obvious?
Code sample below:
class Program
{
static void Main(string[] args)
{
//The salt and hash sizes are 16 bytes (128 bits)
int saltSize = 16;
int hashSize = 16;
int iterations = 100000;
RNGCryptoServiceProvider randomness = new RNGCryptoServiceProvider();
byte[] salt = new byte[saltSize];
randomness.GetBytes(salt);
string password = "Mypassissecure7";
byte[] passBytes = Encoding.Default.GetBytes(password);
Rfc2898DeriveBytes pbkdf2 = new Rfc2898DeriveBytes(passBytes, salt, iterations, HashAlgorithmName.SHA512);
byte[] hash = pbkdf2.GetBytes(hashSize);
}
}