Example #1
0
        /// <summary>
        /// Embed the text into the image.
        /// </summary>
        /// <param name="text">The text to embed.</param>
        /// <param name="image">The image to embed the text into.</param>
        /// <param name="sharedKey">The shared key used with the common salt.</param>
        /// <param name="salt">The common salt used to generate the key.</param>
        /// <returns>The image containing the embedded text.</returns>
        public Bitmap EmbedText(string text, Bitmap image, string sharedKey, byte[] salt)
        {
            // Create a new derived key.
            byte[] cryptoKey = Nequeo.Cryptography.RandomDerivedKey.Generate(sharedKey, salt);
            Nequeo.Cryptography.AdvancedAES aes = new Cryptography.AdvancedAES();

            // Encrypt the key.
            byte[] encryptedText = aes.EncryptToMemory(Encoding.Default.GetBytes(text), cryptoKey);
            string textBase64    = Nequeo.Conversion.Context.ByteArrayToHexString(encryptedText);

            // Create the image.
            return(Nequeo.Drawing.TextEmbedding.EmbedText(textBase64, image));
        }