Exemplo n.º 1
0
        public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger)
        {
            var form = new OptionForm();

            if (form.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            slLogger.SetText("Decrypting backup...", LogStatusType.Info);

            var pfp     = new PfpConvert();
            var protect = Util.GetMemoryProtection(pwStorage.MemoryProtection);

            protect.Add("PIN");
            protect.Add("PUK");
            protect.Add("CVV");

            var entries = pfp.Load(sInput, form.MasterPassword);
            var pw      = pfp.GetPasswordGetter(form.MasterPassword);

            var i = 0;

            foreach (var baseentry in entries)
            {
                if (!(baseentry is PassEntry entry))
                {
                    continue;
                }

                slLogger.SetText($"Importing {entry.name}@{entry.site}...", LogStatusType.Info);

                var pwEntry = Util.GetKeepassEntry(entry, pw, protect);

                pwStorage.RootGroup.AddEntry(pwEntry, true);
                i++;
            }

            slLogger.SetText($"Imported {i} entries.", LogStatusType.Info);
        }
Exemplo n.º 2
0
        public override bool Export(PwExportInfo pwExportInfo, Stream sOutput, IStatusLogger slLogger)
        {
            var form = new OptionForm();

            if (form.ShowDialog() != DialogResult.OK)
            {
                return(false);
            }

            slLogger.SetText("Collecting entries...", LogStatusType.Info);

            var entries = ConvertGroup(pwExportInfo.DataGroup, slLogger);

            slLogger.SetText("Encrypting backup...", LogStatusType.Info);

            var pfp = new PfpConvert();

            pfp.Save(sOutput, form.MasterPassword, entries);

            slLogger.SetText($"Exported {entries.Count} entries.", LogStatusType.Info);

            return(true);
        }