diff --git a/SabreTools.Library/Tools/Utilities.cs b/SabreTools.Library/Tools/Utilities.cs index 68617b83..c4e418d5 100644 --- a/SabreTools.Library/Tools/Utilities.cs +++ b/SabreTools.Library/Tools/Utilities.cs @@ -2152,6 +2152,12 @@ namespace SabreTools.Library.Tools /// http://stackoverflow.com/questions/311165/how-do-you-convert-byte-array-to-hexadecimal-string-and-vice-versa public static string ByteArrayToString(byte[] bytes) { + // If we get null in, we send null out + if (bytes == null) + { + return null; + } + try { string hex = BitConverter.ToString(bytes); @@ -2171,6 +2177,12 @@ namespace SabreTools.Library.Tools /// http://stackoverflow.com/questions/311165/how-do-you-convert-byte-array-to-hexadecimal-string-and-vice-versa public static byte[] StringToByteArray(string hex) { + // If we get null in, we send null out + if (hex == null) + { + return null; + } + try { int NumberChars = hex.Length; @@ -2193,6 +2205,12 @@ namespace SabreTools.Library.Tools /// http://stackoverflow.com/questions/5613279/c-sharp-hex-to-ascii public static string ConvertHexToAscii(string hexString) { + // If we get null in, we send null out + if (hexString == null) + { + return null; + } + if (hexString.Contains("-")) { hexString = hexString.Replace("-", ""); @@ -2217,6 +2235,12 @@ namespace SabreTools.Library.Tools /// http://stackoverflow.com/questions/15920741/convert-from-string-ascii-to-string-hex public static string ConvertAsciiToHex(string asciiString) { + // If we get null in, we send null out + if (asciiString == null) + { + return null; + } + string hexOutput = ""; foreach (char _eachChar in asciiString.ToCharArray()) {