Incog.Steganography.WebPageSteganography.WriteValue C# (CSharp) Method

WriteValue() public method

Write -- encode, encrypt, and hide the steganographic message.
public WriteValue ( string value ) : void
value string The text value to write into the page.
return void
        public void WriteValue(string value)
        {
            Cryptkeeper myCrypt = new Cryptkeeper(this.passphrase);

            byte[] cipherBytes = myCrypt.GetBytes(value, Cryptkeeper.Action.Encrypt);
            byte[] cleartext = myCrypt.GetBytes(cipherBytes, Cryptkeeper.Action.Decrypt);

            byte[] lengthBytes = BitConverter.GetBytes((uint)cipherBytes.Length);
            byte[] buffer = new byte[lengthBytes.Length + cipherBytes.Length];

            Array.Copy(lengthBytes, 0, buffer, 0, lengthBytes.Length);
            Array.Copy(cipherBytes, 0, buffer, lengthBytes.Length, cipherBytes.Length);

            this.EmbedBytesInPage(buffer);

            // If this is a file info, write the bytes down to the file while preserving the file dates
            if (this.isFileInfo)
            {
                // Write the bytes to the file and then reset last access time.
                DateTime created = this.webPageFile.CreationTime;
                DateTime modified = this.webPageFile.LastWriteTime;
                DateTime accessed = this.webPageFile.LastAccessTime;

                BinaryWriter writeFile = new BinaryWriter(File.Open(this.webPageFile.FullName, FileMode.Create));
                writeFile.Write(this.GetBytes());
                writeFile.Close();

                this.webPageFile.CreationTime = created;
                this.webPageFile.LastWriteTime = modified;
                this.webPageFile.LastAccessTime = accessed;
            }
        }

Usage Example

コード例 #1
0
 /// <summary>
 /// Provides a record-by-record processing functionality for the cmdlet.
 /// </summary>
 protected override void ProcessRecord()
 {
     WebPageSteganography stegoPage = new WebPageSteganography(this.Path, this.Passphrase);
     stegoPage.WriteValue(this.Message);
     string check = stegoPage.ReadValue();
     this.WriteVerbose(check);
     this.WriteObject("Message saved.");
 }
All Usage Examples Of Incog.Steganography.WebPageSteganography::WriteValue