Ejemplo n.º 1
0
        private static int DecryptInt(int input, RgssDecryptionKey key)
        {
            var dec = (int)(input ^ key.Current());

            key.Step();
            return(dec);
        }
Ejemplo n.º 2
0
 private static string DecryptString(byte[] input, RgssDecryptionKey key)
 {
     byte[] decBytes = new byte[input.Length];
     for (int i = 0; i < decBytes.Length; i++)
     {
         decBytes[i] = (byte)(input[i] ^ (key.Current() & 0xFF));
         key.Step();
     }
     return(Encoding.UTF8.GetString(decBytes));
 }
Ejemplo n.º 3
0
        private static string DecryptString(byte[] input, RgssDecryptionKey key)
        {
            byte[] decBytes = new byte[input.Length];
            var    j        = 0;

            for (var i = 0; i < decBytes.Length; i++)
            {
                decBytes[i] = (byte)(input[i] ^ ((key.Current() >> 8 * j) & 0xFF));
                j          += 1;
                j          %= 4;
            }
            return(Encoding.UTF8.GetString(decBytes));
        }
Ejemplo n.º 4
0
        public override int Read(byte[] buffer, int offset, int count)
        {
            var read = _fileRange.Read(buffer, offset, count);

            int j = 0;

            for (int i = 0; i < read; i++)
            {
                buffer[offset + i] = (byte)(buffer[offset + i] ^ ((_decKey.Current() >> 8 * j) & 0xFF));

                if ((j = ++j % 4) == 0)
                {
                    _decKey.Step();
                }
            }

            return(read);
        }
Ejemplo n.º 5
0
        public RgssArchiveV1(string path) : base(path)
        {
            using (var fs = File.OpenRead(path))
            {
                switch (CheckVersion(path, 1))
                {
                case -1:
                    throw new InvalidDataException("Invalid RGSS Data");

                case 0:
                    throw new InvalidDataException("Invalid RGSSAD Version");

                case 1:
                default:
                    break;
                }
                using (var br = new BinaryReader(fs))
                {
                    fs.Position = 8;
                    var dKey = new RgssDecryptionKey(7, 3);
                    dKey.PushState(0xDEADCAFE);

                    while (fs.Length - fs.Position > 0)
                    {
                        var fp = new RgssFilePointer();

                        fp.Source    = this;
                        fp.Name      = ReadEncryptedString(br, dKey);
                        fp.Size      = ReadEncryptedInt(br, dKey);
                        fp.Offset    = fs.Position;
                        fp.Key       = dKey.Current();
                        fs.Position += fp.Size;

                        FilePointers.Add(fp);
                    }
                }
            }
        }
Ejemplo n.º 6
0
 private static int DecryptInt(int input, RgssDecryptionKey key)
 {
     return((int)(input ^ key.Current()));
 }