using System; namespace V2GProtocol { /// /// 헥스 문자열 변환 헬퍼 클래스 /// public static class Helper { /// /// 헥스 문자열을 바이트 배열로 변환 /// /// 헥스 문자열 /// 바이트 배열 public static byte[] FromHexString(string hexString) { if (hexString.Length % 2 != 0) throw new ArgumentException("Invalid hex string length"); byte[] bytes = new byte[hexString.Length / 2]; for (int i = 0; i < bytes.Length; i++) { bytes[i] = Convert.ToByte(hexString.Substring(i * 2, 2), 16); } return bytes; } /// /// 바이트 배열을 헥스 문자열로 변환 /// /// 바이트 배열 /// 헥스 문자열 public static string ToHexString(byte[] bytes) { return BitConverter.ToString(bytes).Replace("-", ""); } } }