public static string Encode(string strEncode)
{
string strReturn = "";// 存储转换后的编码
foreach (short shortx in strEncode.ToCharArray())
{
strReturn += shortx.ToString("X4");
}
return strReturn;
}
public static string Decode(string strDecode)
{
string sResult = "";
for (int i = 0; i < strDecode.Length / 4; i++)
{
sResult += (char)short.Parse(strDecode.Substring(i * 4, 4), global::System.Globalization.NumberStyles.HexNumber);
}
return sResult;
}
字符串与十六进制互相转换 c#
最新推荐文章于 2022-11-22 16:46:33 发布