This commit is contained in:
2018-06-28 23:37:38 +00:00
commit 4518298aaf
152 changed files with 24114 additions and 0 deletions

44
util/HexString.cs Normal file
View File

@@ -0,0 +1,44 @@
using System;
using System.Text;
namespace rockfishCore.Util
{
public static class HexString
{
public static string ToHex(string str)
{
var sb = new StringBuilder();
var bytes = Encoding.ASCII.GetBytes(str);
foreach (var t in bytes)
{
sb.Append(t.ToString("X2"));
}
return sb.ToString(); // returns: "48656C6C6F20776F726C64" for "Hello world"
}
public static string FromHex(string hexString)
{
var bytes = new byte[hexString.Length / 2];
for (var i = 0; i < bytes.Length; i++)
{
bytes[i] = Convert.ToByte(hexString.Substring(i * 2, 2), 16);
}
return Encoding.ASCII.GetString(bytes); // returns: "Hello world" for "48656C6C6F20776F726C64"
}
//eoc
}
//eons
}