reWZ.WZAES.DecryptUnicodeString C# (CSharp) Method

DecryptUnicodeString() private method

private DecryptUnicodeString ( byte ushortChars, bool encrypted = true ) : string
ushortChars byte
encrypted bool
return string
        internal string DecryptUnicodeString(byte[] ushortChars, bool encrypted = true)
        {
            CheckKeyLength(ushortChars.Length);
            return Encoding.Unicode.GetString(DecryptData(ushortChars, encrypted ? _unicodeEncKey : _unicodeKey));
        }

Usage Example

Exemplo n.º 1
0
        /// <summary>Reads a string encoded in WZ format.</summary>
        /// <param name="encrypted"> Whether the string is encrypted. </param>
        /// <returns> The read string. </returns>
        internal string ReadWZString(bool encrypted = true)
        {
            if (Position + 1 > Length)
            {
                throw new WZException("WZ string offset out of bounds");
            }
            int length = ReadSByte();

            if (length == 0)
            {
                return("");
            }
            if (length > 0)
            {
                length = length == 127 ? ReadInt32WithinBounds() : length;
                if (length == 0)
                {
                    return("");
                }
                if (Position + length * 2 > Length)
                {
                    throw new WZException("Not enough bytes to read WZ string");
                }
                byte[] rbytes = ReadBytes(length * 2);
                return(_aes.DecryptUnicodeString(rbytes, encrypted));
            } // !(length >= 0), i think we can assume length < 0, but the compiler can't seem to see that
            length = length == -128 ? ReadInt32WithinBounds() : -length;
            if (Position + length > Length)
            {
                throw new WZException("Not enough bytes to read WZ string");
            }
            return(length == 0 ? "" : _aes.DecryptASCIIString(ReadBytes(length), encrypted));
        }
All Usage Examples Of reWZ.WZAES::DecryptUnicodeString