I have an image & when I convert to Base64 using JavaScript and C#, it gives me two different values. what is the reason for this?
JavaScript Code
function LoadSvg() {
var main = document.getElementById('svgimg');
var data = main.innerHTML;
debugger;
var base64blob = Base64.encode(data);
alert(base64blob);
var image2 = document.getElementById('Img2');
image2.src = 'data:image/svg+xml;base64,' + base64blob;
}
C# code
string val=litSvg.Text;
byte[] arr = Encoding.UTF8.GetBytes(val);
string toBaseVal = Convert.ToBase64String(arr);
ExternalHtml =
"<img id=\"dfs\" src=\"data:image/svg+xml;base64," + toBaseVal + "\" />";
in JavaScript main value and c# val values are same. how this happens? if I need to same same value in java script out put, how can I do that?
Edit :
val value :
<svg xmlns='http://www.w3.org/2000/svg' version='1.1' width='470px' height='310px'><line x1='40' y1='10' x2='40' y2='250'style='stroke: rgb(0,0,0); stroke-width: 1' />...
main value :
<svg id="svg-code" xmlns="http://www.w3.org/2000/svg" version="1.1" width="470px" height="310px"> <line x1="40" y1="10" x2="40" y2="250" style="stroke: rgb(0,0,0); stroke-width: 1"></line>
O/P values :
base64blob : CiAgICAgICAgICAgICAgICA8.....
toBaseVal : PHN2ZyB4bWxucz0naHR0cDov ....