Conversion between Base64String and Hexadecimal

孤街浪徒 提交于 2019-11-29 04:37:49
bryanmac

FromBase64String will take the string to bytes

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

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

string hex = BitConverter.ToString(bytes);
Ranhiru Jude Cooray

Convert the string to a byte array and then do a byte to hex conversion

string stringToConvert = "/MnwRx7kRZEQBxLZEkXndA==";

byte[] convertedByte = Encoding.Unicode.GetBytes(stringToConvert);

string hex = BitConverter.ToString(convertedByte);

Console.WriteLine(hex);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!