Skip to content

Commit

Permalink
write exeptions to logfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Stricted committed Jan 19, 2016
1 parent 13cbbff commit 50b5e32
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions SPHDecode/Implementations/Cryptography.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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))
Expand Down Expand Up @@ -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;
Expand All @@ -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();
}
}
}

0 comments on commit 50b5e32

Please sign in to comment.