예제 #1
0
        public void ExecuteEraseFile()
        {
            HideLSB.Erase(ref this._hiddenImageBitmapCache);
            this.HiddenImage = FileTransform.Bitmap2BitmapImage(this._hiddenImageBitmapCache);

            if (File.Exists(this.ImageFilePath))
            {
                File.Delete(this.ImageFilePath);
            }

            this._hiddenImageBitmapCache.Save(this.ImageFilePath);

            this.ShowMessageBoxResource("RetrieveDone", "Hint", MessageBoxButton.OK, MessageBoxImage.Information);
        }
예제 #2
0
        public void ExecuteHideFile(object args)
        {
            try
            {
                var hideOption = this.GetHideOptionFromView((Window)args);

                if (hideOption == null)
                {
                    return;
                }

                var fileBytesToHide      = FileTransform.File2ByteArray(hideOption.FilePath);
                var zipedCoverImageBytes = Zip.Compress(fileBytesToHide);

                IEncryption encryptor = EncryptionFactory.CreateEncryption(hideOption.EncryptionAlg);

                var ciphertext = encryptor.Encrypt(zipedCoverImageBytes, this.StrPassword2UintArr(hideOption.Password));

                var tmpBitmapCacheToHide =
                    this._coverImageBitmapCache.Clone(
                        new Rectangle(0, 0, this._coverImageBitmapCache.Width, this._coverImageBitmapCache.Height),
                        this._coverImageBitmapCache.PixelFormat);

                HideLSB.Hide(ref tmpBitmapCacheToHide, ciphertext);

                this._hiddenImageBitmapCache = tmpBitmapCacheToHide;
                this.HiddenImage             = FileTransform.Bitmap2BitmapImage(this._hiddenImageBitmapCache);
            }
            catch (ImageHideCapacityTooSmallException)
            {
                this.ShowMessageBoxResource("HidingCapacityNotEnough", "Hint", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch (IOException)
            {
                this.ShowMessageBoxResource("FileOpenError", "Error");
            }
            catch (Exception)
            {
                this.ShowMessageBoxResource("UnknownError", "Error");
            }
        }