标签:code 大写 tostring input each 方式 收藏 enc 方便
var str = DateTime.Now.ToString();
var encode = Encoding.UTF8;
var bytes = encode.GetBytes(str);
StringBuilder ret = new StringBuilder();
foreach (byte b in bytes)
{
//{0:X2} 大写
ret.AppendFormat("{0:x2}", b);
}
var hex = ret.ToString();
Console.WriteLine(hex);
var inputByteArray = new byte[hex.Length / 2];
for (var x = 0; x < inputByteArray.Length; x++)
{
var i = Convert.ToInt32(hex.Substring(x * 2, 2), 16);
inputByteArray[x] = (byte)i;
}
str = encode.GetString(inputByteArray);
Console.WriteLine(str);
//网络素材仅限收藏 方便学习
标签:code 大写 tostring input each 方式 收藏 enc 方便
原文地址:https://www.cnblogs.com/New-HackerHK/p/14905597.html