using System;

namespace Core.KCPTool
{

    public class SocketTool
    {
        public static byte[] LongToByte(long number)
        {
            byte[] numberBytes = BitConverter.GetBytes(number);
            return numberBytes;
        }

        public static long ByteToLong(byte[] numberBytes)
        {
            long converted = BitConverter.ToInt64(numberBytes, 0);
            return converted;
        }
        
        public static int ByteToInt(byte[] numberBytes)
        {
            int converted = BitConverter.ToInt32(numberBytes, 0);
            return converted;
        }

        public static byte[] IntToByte(int number)
        {
            byte[] numberBytes = BitConverter.GetBytes(number);
            return numberBytes;
        }

     

        public static int ByteToInt(byte[] numberBytes, bool isReverse = false)
        {
            if (isReverse)
            {
                int converted = BitConverter.ToInt32(numberBytes, 0);
                return converted;
            }
            else
            {
                int converted = BitConverter.ToInt32(numberBytes, 0);
                return converted;
            }
        }
    }
}