Base64String和十六进制之间的转换Base64String、十六进制

2023-09-03 04:05:58 作者:先森, 我们慢慢变老

我在C ++ / CLI的项目中使用 ToBase64String 来给像一个字符串 / MnwRx7kRZEQBxLZEkXndA == 我要将此字符串转换为十六进制再presentation,我该怎么做,在C ++ / CLI或C#?

I use in my C++/CLI project ToBase64String to give a string like /MnwRx7kRZEQBxLZEkXndA== I want to convert this string to Hexadecimal representation, How I can do that in C++/CLI or C#?

推荐答案

FromBase64String将采取字符串字节取值

byte[] bytes = Convert.FromBase64String(string s);

然后, BitConverter.ToString()将一个字节数组到十六进制字符串(的 C#字节[]以十六进制字符串)

Then, BitConverter.ToString() will convert a byte array to a hex string ( C# byte[] to hex string )

string hex = BitConverter.ToString(data);