コード例 #1
0
        /// <summary>
        /// Processes input data.
        /// </summary>
        /// <param name="FileContent">Signed data bytes</param>
        /// <param name="Signature">Signature to neutralize</param>
        public Reader(byte[] FileContent, BinarySignature Signature)
        {
            this.FileContent = FileContent;
            this.Signature   = Signature;

            this.SignatureHeader = new byte[this.Signature.getHeader().Length];
            this.SignatureFooter = new byte[this.Signature.getFooter().Length];

            System.Array.Copy(this.FileContent, 0, this.SignatureHeader, 0, this.Signature.getHeader().Length);
            System.Array.Copy(this.FileContent, this.FileContent.Length - this.Signature.getFooter().Length, SignatureFooter, 0, this.Signature.getFooter().Length);

            if (System.Linq.Enumerable.SequenceEqual(this.Signature.getHeader(), this.SignatureHeader))
            {
                if (System.Linq.Enumerable.SequenceEqual(this.Signature.getFooter(), this.SignatureFooter))
                {
                    this.Output = new byte[this.FileContent.Length - this.Signature.getHeader().Length - this.Signature.getFooter().Length];
                    System.Array.Copy(this.FileContent, this.Signature.getHeader().Length, this.Output, 0, this.FileContent.Length - this.Signature.getHeader().Length - this.Signature.getFooter().Length);
                }
                else
                {
                    throw new System.ArgumentOutOfRangeException();
                }
            }
            else
            {
                throw new System.ArgumentOutOfRangeException();
            }
        }
コード例 #2
0
        /// <summary>
        /// Processes input data.
        /// </summary>
        /// <param name="FileContent">Plain string</param>
        /// <param name="Signature">Signature to apply</param>
        public Creator(string FileContent, BinarySignature Signature)
        {
            this.FileContent = System.Text.Encoding.ASCII.GetBytes(FileContent);
            this.Signature   = Signature;

            this.Output = new byte[this.Signature.getHeader().Length + this.FileContent.Length + this.Signature.getFooter().Length];
            System.Array.Copy(this.Signature.getHeader(), 0, this.Output, 0, this.Signature.getHeader().Length);
            System.Array.Copy(this.FileContent, 0, this.Output, this.Signature.getHeader().Length, this.FileContent.Length);
            System.Array.Copy(this.Signature.getFooter(), 0, this.Output, this.Signature.getHeader().Length + this.FileContent.Length, this.Signature.getFooter().Length);
        }
コード例 #3
0
        /// <summary>
        /// Processes input data.
        /// </summary>
        /// <param name="FileContent">Plain data bytes</param>
        /// <param name="Signature">Signature to apply</param>
        public Creator(byte[] FileContent, BinarySignature Signature)
        {
            this.FileContent = FileContent;
            this.Signature   = Signature;

            this.Output = new byte[this.Signature.getHeader().Length + this.FileContent.Length + this.Signature.getFooter().Length];
            System.Array.Copy(this.Signature.getHeader(), 0, this.Output, 0, this.Signature.getHeader().Length);
            System.Array.Copy(this.FileContent, 0, this.Output, this.Signature.getHeader().Length, this.FileContent.Length);
            System.Array.Copy(this.Signature.getFooter(), 0, this.Output, this.Signature.getHeader().Length + this.FileContent.Length, this.Signature.getFooter().Length);
        }