using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GWSocketClient.util
{
    public class AryUtil
    {
        public static string Bytes2Hex(byte[] bs)
        {
            return BitConverter.ToString(bs, 0, bs.Length).Replace("-", "").ToUpper();
        }


        public static byte[] Hex2Bytes(string hex)
        {
            hex = hex.Replace(" ", "");
            if (hex.Length % 2 != 0)
                hex += " ";
            byte[] returnBytes = new byte[hex.Length / 2];
            for (int i = 0; i < returnBytes.Length; i++)
                returnBytes[i] = Convert.ToByte(hex.Substring(i * 2, 2).Trim(), 16);
            return returnBytes;
        }
    }
}