I know how to convert from string to byte [] in C #. In this particular case, I am working with the string representation of the HMAC-SHA256 key. Let them say that the string representation of this key that I get from OpenID OP:
"81FNybKWfcM539vVGtJrXRmoVMxNmZHY3OgUro8+pZ8="
I convert it to byte [] as follows:
byte[] myByteArr = Encoding.UTF8.GetBytes("81FNybKWfcM539vVGtJrXRmoVMxNmZHY3OgUro8+pZ8=");
The problem I am facing is that it seems to be losing its original data. If I take an array of bytes from the previous step and convert it back to a string, it is different from the original string.
string check = Convert.ToBase64String(myByteArr);
check ends:
"ODFGTnliS1dmY001Mzl2Vkd0SnJYUm1vVk14Tm1aSFkzT2dVcm84K3BaOD0="
which obviously does not match the original string representation that I started with.
source
share