I am trying to send a byte array pulled from my database via C# to my front end client, which is written in JavaScript/TypeScript, but it seems that the byte array is being encoded somewhere between being sent from the back end and getting to the front end.
The data in the database is a varbinary with the value: 0x00000001. I've set a breakpoint where my C# code is returning the retrieved value and I am getting a byte array with the value of: [0, 0, 0, 1]. However, when it gets to the client, the value is: "AAAAAQ==".
I've tried decoding it using the following code:
let encodedString = encodeURI(encodeURIComponent(flag));
let arr = [];
for (let i = 0; i < encodedString.length; i++) {
arr.push(encodedString.charCodeAt(i));
}
But that code returns this array of values: [65, 65, 65, 65, 65, 81, 37, 50, 53, 51, 68, 37, 50, 53, 51, 68]
What is causing the data to be encoded, and how can I either decode it in TypeScript or prevent it from encoded when it is being sent to the client?