I used the following code to convert a bytes array to a string:
byte[] saltBytes;
// ... filling the array with some values
for (int i = 0; i < saltBytes.Length; i++)
{
builder.Append(saltBytes[i].ToString("x2"));
}
string salt = builder.ToString();
Now, I would like to revert this process and convert my string to a bytes array. I was reading this question: Converting string to byte array in C#.
The answer mentions:
If you already have a byte array then you will need to know what type of encoding was used to make it into that byte array.
I'm not sure about the encoding used in the snippet I posted. Does this have to do with the ToString("x2")
part?