问题
I have problem when I transform a byte[]
to a string
.
I have used these ways so far:
System.Text.Encoding.UTF8.GetString(byteArray);
System.Text.Encoding.UTF8.GetString(byteArray);
I use Rijndael in order to encrypt some parameters to send them in an API and I follow this Microsoft-Documentation.
When I encrypt and decrypt as the documentation says everything works fine.
In the documentation there is no need for conversion byte[]
to a string
.
But in order to send it to the API I have to put them in an XML file.
As a result I have to convert the encrypted byte[]
to a string
in order to send it.
So when I send it in this ways I have Bad Credentials
error, it is not acceptable.
So I think that something is wrong with conversion.
When I make some tests with AES-site I have a nice string
result. Like this:
For example:
The text : text
is encrypted to something like this CfsfFYz5u+3psJy8RWV+HA==
This is exactly the expected format , like above (CfsfFYz5u+3psJy8RWV+HA==
).
来源:https://stackoverflow.com/questions/62698275/which-is-the-proper-way-to-convert-a-byte-to-a-string-in-order-to-have-the-exp