Exemple #1
0
        // -----------------------------------------------------------------------------------
        /// <summary>
        /// Loads the images for a given round
        /// </summary>
        public RoundImages LoadRound(int round)
        {
            if (round >= header.availableRounds)
            {
                throw new Exception(string.Concat("Tried to load round: ", round + 1, " but only ", header.availableRounds, " rounds are available"));
            }

            BinaryReader br = new BinaryReader(System.IO.File.Open(source, FileMode.Open));

            BlowFishCS.BlowFish blowfish = new BlowFishCS.BlowFish(IllogicGate.Data.EncryptedFile.RestoreKey(ShuffledKey));

            // read and decrypt the round image and shadow
            br.BaseStream.Seek(header.roundBase[round].offset, SeekOrigin.Begin);
            byte[] rawBase = br.ReadBytes(header.roundBase[round].length);
            rawBase = blowfish.Decrypt_ECB(rawBase);
            rawBase = LZMAtools.DecompressLZMAByteArrayToByteArray(rawBase);

            br.BaseStream.Seek(header.roundShadow[round].offset, SeekOrigin.Begin);
            byte[] rawShadow = br.ReadBytes(header.roundShadow[round].length);
            rawShadow = blowfish.Decrypt_ECB(rawShadow);
            rawShadow = LZMAtools.DecompressLZMAByteArrayToByteArray(rawShadow);

            br.Close();

            return(new RoundImages(rawBase, rawShadow, header.isPortrait[round]));
        }
Exemple #2
0
 /// <summary>
 /// BlowFish解密bytes
 /// </summary>
 /// <param name="decodeStr"></param>
 /// <param name="key"></param>
 /// <returns></returns>
 public static byte[] BlowFishDecryptBytes(byte[] bytes, string key)
 {
     byte[] keys = ASCIIEncoding.ASCII.GetBytes(key);
     BlowFishCS.BlowFish blowFish = new BlowFishCS.BlowFish(keys);
     byte[] result = blowFish.Decrypt_ECB(bytes);
     return(result);
 }
        // --- Class Declaration ------------------------------------------------------------------------
        // -----------------------------------------------------------------------------------
        /// <summary>
        /// Reads bytes from an encrypted file
        /// </summary>
        /// <param name="path">Path of the file</param>
        /// <param name="shuffledKey">Optional encryption key (shuffled with Util.ShuffleKey)</param>
        /// <returns>A byte array with the decrypted data</returns>
        public static byte[] ReadBytes(string path, string shuffledKey = DefaultShuffledKey)
        {
            FileStream stream = new FileStream(path, FileMode.Open);

            byte [] data = new byte[stream.Length];
            stream.Read(data, 0, data.Length);
            stream.Close();

            BlowFishCS.BlowFish blowfish = new BlowFishCS.BlowFish(RestoreKey(shuffledKey));
            return(blowfish.Decrypt_ECB(data));
        }
Exemple #4
0
        // -----------------------------------------------------------------------------------
        /// <summary>
        /// Loads and decrypts a character sheet from file
        /// </summary>
        void LoadCharacterSheet()
        {
            BinaryReader br = new BinaryReader(System.IO.File.Open(source, FileMode.Open));

            BlowFishCS.BlowFish blowfish = new BlowFishCS.BlowFish(IllogicGate.Data.EncryptedFile.RestoreKey(ShuffledKey));

            // read and decrypt the character sheet
            br.BaseStream.Seek(header.characterSheet.offset, SeekOrigin.Begin);
            byte[] rawData = br.ReadBytes(header.characterSheet.length);
            rawData = blowfish.Decrypt_ECB(rawData);
            rawData = LZMAtools.DecompressLZMAByteArrayToByteArray(rawData);
            br.Close();

            _characterSheet = new BaseSheet(rawData);
        }