Base64String和hex之间的转换
我在我的C ++ / CLI项目ToBase64String
了一个字符串,如/MnwRx7kRZEQBxLZEkXndA==
我想将此字符串转换为hex表示,如何在C ++ / CLI或C#中执行此操作?
FromBase64String将string
为byte
s
byte[] bytes = Convert.FromBase64String(string s);
然后, BitConverter.ToString()
将字节数组转换为hex字符串( byte []到hex字符串 )
string hex = BitConverter.ToString(data);
将字符串转换为字节数组,然后执行字节到hex转换
string stringToConvert = "/MnwRx7kRZEQBxLZEkXndA=="; byte[] convertedByte = Encoding.Unicode.GetBytes(stringToConvert); string hex = BitConverter.ToString(convertedByte); Console.WriteLine(hex);