Ejemplo n.º 1
0
            public static async Task Save(string type)
            {
                FileSavePicker fs  = new FileSavePicker();
                string         ext = Bifid_Cipher.Decrypt(Encoding.ASCII.GetString(((List <byte>)GetData.Extract[Data.Misc.DataExtension]).ToArray()));

                fs.FileTypeChoices.Add(Validate.IsType(ext), new List <string>()
                {
                    ext
                });
                fs.SuggestedFileName = Bifid_Cipher.Decrypt(Encoding.ASCII.GetString(((List <byte>)GetData.Extract[Data.Misc.DataNameFile]).ToArray()));
                StorageFile sf = await fs.PickSaveFileAsync();

                if (sf != null)
                {
                    switch (type)
                    {
                    case "File":
                        await FileIO.WriteBytesAsync(sf, ((List <byte>)GetData.Extract[Data.Misc.DataSecret]).ToArray());

                        break;

                    case "Message":
                        await FileIO.WriteTextAsync(sf, await Bifid_Cipher.Execute("Extract", Encoding.ASCII.GetString(((List <byte>)GetData.Extract[Data.Misc.DataSecret]).ToArray()), String.Empty));

                        break;
                    }
                    ToastDialog.ShowData(sf, Validate.IsType(ext), "Embedded File", Detail.Extract_FileMessage);
                    await PopupDialog.Show(Status.Success, Detail.Extract_FileMessage, Complete.Saved_SecretFile, Icon.Smile);
                }
                else
                {
                    await PopupDialog.Show(Status.Err, Detail.Extract_FileMessage, Err.NotSaved_SecretFile, Icon.Sad);
                }
            }
Ejemplo n.º 2
0
            public static async Task Save(Dictionary <string, object> value, string type)
            {
                FileSavePicker fs = new FileSavePicker();

                fs.FileTypeChoices.Add("Stego Image Files", new List <string>()
                {
                    ".png"
                });
                StorageFile sf = await fs.PickSaveFileAsync();

                if (sf != null)
                {
                    using (IRandomAccessStream ram = await sf.OpenAsync(FileAccessMode.ReadWrite))
                    {
                        BitmapEncoder encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, ram);

                        //var memStream = new InMemoryRandomAccessStream();
                        //BitmapEncoder encoder = await BitmapEncoder.CreateForTranscodingAsync(memStream, GetData.Decoder);
                        encoder.SetPixelData(GetData.Decoder.BitmapPixelFormat, GetData.Decoder.BitmapAlphaMode, (uint)GetData.Decoder.PixelWidth, (uint)GetData.Decoder.PixelHeight, GetData.Decoder.DpiX, GetData.Decoder.DpiY, (byte[])value[Data.Misc.DataPixel]);
                        var prop = new List <KeyValuePair <string, BitmapTypedValue> >();

                        var desc = new BitmapTypedValue(String.Format("{0}|{1}|{2}|{3}|{4}", (int)value[Data.Misc.DataPassword], (int)value[Data.Misc.DataType], (int)value[Data.Misc.DataNameFile], (int)value[Data.Misc.DataExtension], (int)value[Data.Misc.DataSecret]), PropertyType.String);
                        prop.Add(new KeyValuePair <string, BitmapTypedValue>(Data.Misc.Secret, desc));

                        await encoder.BitmapProperties.SetPropertiesAsync(prop);

                        await encoder.FlushAsync();

                        //memStream.Seek(0);
                        //ram.Seek(0);
                        //ram.Size = 0;
                        //await RandomAccessStream.CopyAsync(memStream, ram);
                        //memStream.Dispose();
                    }
                    switch (type)
                    {
                    case "File":
                        ToastDialog.ShowData(sf, "Image Files", "Stego Image", Detail.Embed_File);
                        await PopupDialog.Show(Status.Success, Detail.Embed_File, Complete.Saved_StegoImage, Icon.Smile);

                        break;

                    case "Message":
                        ToastDialog.ShowData(sf, "Image Files", "Stego Image", Detail.Embed_Message);
                        await PopupDialog.Show(Status.Success, Detail.Embed_Message, Complete.Saved_StegoImage, Icon.Smile);

                        break;
                    }
                }
                else
                {
                    switch (type)
                    {
                    case "File":
                        await PopupDialog.Show(Status.Err, Detail.Embed_File, Err.NotSaved_StegoImage, Icon.Sad);

                        break;

                    case "Message":
                        await PopupDialog.Show(Status.Err, Detail.Embed_Message, Err.NotSaved_StegoImage, Icon.Sad);

                        break;
                    }
                }
            }