Exemplo n.º 1
0
        //Direct Compression/Decompression
        public CompressString(System.Text.Encoding TextEncoding, string InputString, InputDataTypeClass InputDataType, string Passphrase = "", string PrefixForCompressedString = "", string SuffixForCompressedString = "")
        {
            this._TextEncoding = TextEncoding;
            this._PrefixForCompressedString = PrefixForCompressedString;
            this._SuffixForCompressedString = SuffixForCompressedString;
            this._Passphrase = Passphrase;

            switch (InputDataType)
            {
                case InputDataTypeClass.UnCompressed:
                    this._UnCompressed = InputString;
                    this.Compress();
                    break;
                case InputDataTypeClass.Compressed:
                    string Result = InputString;
                    if (Result.Length > 0 & Result.Length > (this._PrefixForCompressedString.Length + this._SuffixForCompressedString.Length))
                    {
                        if (this._PrefixForCompressedString.Length > 0)
                        {
                            Result = InputString.Substring(this._PrefixForCompressedString.Length, Result.Length - this._PrefixForCompressedString.Length);
                        }
                        if (this._SuffixForCompressedString.Length > 0)
                        {
                            Result = Result.Substring(0, Result.Length - this._SuffixForCompressedString.Length);
                        }
                    }
                    this._Compressed = Result;
                    this._CompressedGiven = true;
                    this.Decompress();
                    break;
            }
        }
Exemplo n.º 2
0
        //Direct Compression/Decompression

        public CompressString(System.Text.Encoding TextEncoding, string InputString, InputDataTypeClass InputDataType, string Passphrase = "", string PrefixForCompressedString = "", string SuffixForCompressedString = "")
        {
            this._TextEncoding = TextEncoding;
            this._PrefixForCompressedString = PrefixForCompressedString;
            this._SuffixForCompressedString = SuffixForCompressedString;
            this._Passphrase = Passphrase;

            switch (InputDataType)
            {
            case InputDataTypeClass.UnCompressed:
                this._UnCompressed = InputString;
                this.Compress();
                break;

            case InputDataTypeClass.Compressed:
                string Result = InputString;
                if (Result.Length > 0 & Result.Length > (this._PrefixForCompressedString.Length + this._SuffixForCompressedString.Length))
                {
                    if (this._PrefixForCompressedString.Length > 0)
                    {
                        Result = InputString.Substring(this._PrefixForCompressedString.Length, Result.Length - this._PrefixForCompressedString.Length);
                    }
                    if (this._SuffixForCompressedString.Length > 0)
                    {
                        Result = Result.Substring(0, Result.Length - this._SuffixForCompressedString.Length);
                    }
                }
                this._Compressed      = Result;
                this._CompressedGiven = true;
                this.Decompress();
                break;
            }
        }