コード例 #1
0
        private void extractClick() //error checking needed here
        {
            SetPrimaryStatusLabelText("Extraction Running");
            Stopwatch s = new Stopwatch();

            s.Start();
            string imgPath    = pictureInBox.Text;
            string msgInPath  = messageInBox.Text;
            string msgOutPath = messageOutBox.Text;
            string password   = passBox.Text;
            Bitmap b          = new Bitmap(imgPath);

            byte[] messageBytes = File.ReadAllBytes(msgInPath);

            if (!StegoHandler.checkHash(password, b))
            {
                SetPrimaryStatusLabelText("Error: Wrong password or not a Stego Image");
            }
            else
            {
                byte[] otp          = StegoHandler.extractMain(password, b);
                byte[] decryptedOTP = AES.decryptionMain(password, otp);
                decryptedOTP = StegoHandler.chopEOF(decryptedOTP);

                byte[] postOTPMsgBytes = OTPHandler.extractEncryptedMessage(decryptedOTP, messageBytes);
                //check password here--don't need to w/ no encryption though

                //postOTPMsgBytes=AES.decryptionMain(password, postOTPMsgBytes); //I think encrypting this might be useless.
                byte[] finalMsgBytes = OTPHandler.chopEOF(postOTPMsgBytes);

                File.WriteAllBytes(msgOutPath, finalMsgBytes);
                s.Stop();
                SetPrimaryStatusLabelText("Extraction Complete. Time: " + s.ElapsedMilliseconds + "ms.");
            }
        }
コード例 #2
0
        private void implantClick() //error checking needed here
        {
            SetPrimaryStatusLabelText("Implantation Running");
            Stopwatch s = new Stopwatch();

            s.Start();
            string imgPath    = pictureInBox.Text;
            string msgPath    = messageInBox.Text;
            string picOutPath = picOutBox.Text;
            string msgOutPath = messageOutBox.Text;
            string password   = pass1Box.Text;
            Bitmap b          = new Bitmap(imgPath);

            byte[] OTP = OTPHandler.generateRandomBytes(StegoHandler.availableBytes(b.Width * b.Height));

            byte[] unencryptedMsg = File.ReadAllBytes(msgPath);

            if (unencryptedMsg.Length > OTP.Length - OTPHandler.EOF1_LENGTH - 1)
            {
                SetPrimaryStatusLabelText("Error: Message cannot be longer than image can handle.");
                return;
            }
            byte[] messageBytes = OTPHandler.addEOF(unencryptedMsg);                 //some nuances need to be resolved here when message approaches the length of the OTP.
            //byte[] encryptedMsg = AES.encryptionMain(password, messageBytes);
            byte[] finalMessage = OTPHandler.getEncryptedMessage(OTP, messageBytes); //this saves to finalMessage.

            byte[] OTPwEOF = OTPHandler.addEOF(OTP);
            OTPwEOF = AES.encryptionMain(password, OTPwEOF);
            Console.WriteLine("Time to encryption: " + s.ElapsedMilliseconds);
            b = StegoHandler.implantMain(password, b, OTPwEOF);
            Console.WriteLine("Time to implant: " + s.ElapsedMilliseconds);

            b.Save(picOutPath, ImageFormat.Png);
            File.WriteAllBytes(msgOutPath, finalMessage);
            s.Stop();
            SetPrimaryStatusLabelText("Implantation Complete. Time: " + s.ElapsedMilliseconds + "ms.");
        }