Home > Net >  To base64 decoding of string, and then converted to hexadecimal
To base64 decoding of string, and then converted to hexadecimal

Time:09-15

ZmLVuCs4H/zX6E63 + i2Ung==base64 decoding, the decoding into hexadecimal is 66 62 D5 B8 2 b 38 FC 1 f D7 E8 B7 FA 94 9 e 2 d, 4 e

Could you tell me how to convert the above is to come over?
I am such operation, but the result is wrong:

Byte [] bytes=the Convert. FromBase64String (" ZmLVuCs4H/zX6E63 + i2Ung==");
String=base64 Encoding. UTF8. Get string (bytes);
Response. Write (GetHexFromChs (output));

//string converted to hexadecimal
Public static string GetHexFromChs (string s)
{
If ((s.L ength % 2)!=0)
{
S +="";//space
//throw new ArgumentException (" s is not valid Chinese string!" );
}

System. Text. Encoding CHS=System. Text.. Encoding UTF8;

Byte [] bytes=CHS. GetBytes (s);

String STR="";

for (int i=0; I & lt; Bytes. The Length; I++)
{
STR +=the string. Format ("} {0: X ", bytes [I]);
}

return str;
}

CodePudding user response:

Var hex="";
The foreach (var b in bytes)
{
Hex +=b.T oString (" x2 ");
}

CodePudding user response:

Show one reply on the BBS, how do I point open to see other people's reply??

CodePudding user response:

This time CSDN is tic, ah, it seems to be cold,
  • Related