From 50b5e32490d50a6836251441a5a6a8ed5f8914c1 Mon Sep 17 00:00:00 2001 From: Stricted Date: Tue, 19 Jan 2016 21:23:52 +0100 Subject: [PATCH] write exeptions to logfile --- SPHDecode/Implementations/Cryptography.cs | 51 ++++++++++++----------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/SPHDecode/Implementations/Cryptography.cs b/SPHDecode/Implementations/Cryptography.cs index 24731cf..4c930d9 100644 --- a/SPHDecode/Implementations/Cryptography.cs +++ b/SPHDecode/Implementations/Cryptography.cs @@ -41,7 +41,8 @@ public static string Decrypt(byte[] clearText) } catch (Exception ex) { - throw ex; + LogManager.WriteToLog(ex.Message); + // TODO: show error message } if (response.EndsWith("\0")) @@ -53,39 +54,19 @@ public static string Decrypt(byte[] clearText) } else { - // show error + // TODO: show error message } return string.Empty; } - public static string DecompressData(byte[] data) - { - MemoryStream stream = new MemoryStream(data, 2, data.Length - 2); - DeflateStream inflater = new DeflateStream(stream, CompressionMode.Decompress); - StreamReader streamReader = new StreamReader(inflater); - - return streamReader.ReadToEnd(); - } - - public static byte[] CompressData(byte[] data) - { - MemoryStream ms = new MemoryStream(); - Stream s = new zlib.ZOutputStream(ms, 9); - s.Write(data, 0, data.Length); - s.Close(); - - return ms.ToArray(); - } - - public static byte[] Enecrypt(string data) { - byte[] response; + byte[] response = null; if (IsXML(data).Equals(false)) { - // show error + // TODO: show error message } if (data.EndsWith("\0").Equals(false)) @@ -120,7 +101,8 @@ public static byte[] Enecrypt(string data) } catch (Exception ex) { - throw ex; + LogManager.WriteToLog(ex.Message); + // TODO: show error message } return response; @@ -135,5 +117,24 @@ public static bool IsXML(string xml) return false; } + + public static string DecompressData(byte[] data) + { + MemoryStream stream = new MemoryStream(data, 2, data.Length - 2); + DeflateStream inflater = new DeflateStream(stream, CompressionMode.Decompress); + StreamReader streamReader = new StreamReader(inflater); + + return streamReader.ReadToEnd(); + } + + public static byte[] CompressData(byte[] data) + { + MemoryStream ms = new MemoryStream(); + Stream s = new zlib.ZOutputStream(ms, 9); + s.Write(data, 0, data.Length); + s.Close(); + + return ms.ToArray(); + } } }