Advertisement
Guest User

Decrypter.cs

a guest
Jan 19th, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using SevenZip;
  2. using SevenZip.Compression.LZMA;
  3. using System.IO;
  4.  
  5. namespace LuaDecrypter
  6. {
  7.   internal class Decrypter
  8.   {
  9.     public const int JUNK_SIZE = 4;
  10.     public const int PROPERTIES_SIZE = 5;
  11.  
  12.     public bool Decrypt(Stream inStream, Stream outStream, bool removeJunk = false, int junkSize = 4)
  13.     {
  14.       if (removeJunk)
  15.         inStream.Seek((long) junkSize, SeekOrigin.Begin);
  16.       byte[] numArray = new byte[5];
  17.       if (inStream.Read(numArray, 0, 5) != 5)
  18.         return false;
  19.       Decoder decoder = new Decoder();
  20.       decoder.SetDecoderProperties(numArray);
  21.       long outSize = 0L;
  22.       for (int index = 0; index < 8; ++index)
  23.       {
  24.         int num = inStream.ReadByte();
  25.         if (num < 0)
  26.           return false;
  27.         outSize |= (long) (byte) num << 8 * index;
  28.       }
  29.       long inSize = inStream.Length - inStream.Position;
  30.       decoder.Code(inStream, outStream, inSize, outSize, (ICodeProgress) null);
  31.       return true;
  32.     }
  33.   }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement