• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# KeePassLib.PwDatabase类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中KeePassLib.PwDatabase的典型用法代码示例。如果您正苦于以下问题:C# PwDatabase类的具体用法?C# PwDatabase怎么用?C# PwDatabase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PwDatabase类属于KeePassLib命名空间,在下文中一共展示了PwDatabase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Copy

		public static bool Copy(ProtectedString psToCopy, bool bIsEntryInfo,
			PwEntry peEntryInfo, PwDatabase pwReferenceSource)
		{
			if(psToCopy == null) throw new ArgumentNullException("psToCopy");
			return Copy(psToCopy.ReadString(), true, bIsEntryInfo, peEntryInfo,
				pwReferenceSource, IntPtr.Zero);
		}
开发者ID:dbremner,项目名称:keepass2,代码行数:7,代码来源:ClipboardUtil.cs


示例2: Import

		public static bool? Import(PwDatabase pwStorage, out bool bAppendedToRootOnly,
			Form fParent)
		{
			bAppendedToRootOnly = false;

			if(pwStorage == null) throw new ArgumentNullException("pwStorage");
			if(!pwStorage.IsOpen) return null;
			if(!AppPolicy.Try(AppPolicyId.Import)) return null;

			ExchangeDataForm dlgFmt = new ExchangeDataForm();
			dlgFmt.InitEx(false, pwStorage, pwStorage.RootGroup);

			if(dlgFmt.ShowDialog() == DialogResult.OK)
			{
				Debug.Assert(dlgFmt.ResultFormat != null);
				if(dlgFmt.ResultFormat == null)
				{
					MessageService.ShowWarning(KPRes.ImportFailed);
					return false;
				}

				bAppendedToRootOnly = dlgFmt.ResultFormat.ImportAppendsToRootGroupOnly;

				List<IOConnectionInfo> lConnections = new List<IOConnectionInfo>();
				foreach(string strSelFile in dlgFmt.ResultFiles)
					lConnections.Add(IOConnectionInfo.FromPath(strSelFile));

				return Import(pwStorage, dlgFmt.ResultFormat, lConnections.ToArray(),
					false, null, false, fParent);
			}

			return null;
		}
开发者ID:ComradeP,项目名称:KeePass-2.x,代码行数:33,代码来源:ImportUtil.cs


示例3: ImportRecord

		private static void ImportRecord(Node<BaseRecord> currentNode, PwGroup groupAddTo, PwDatabase pwStorage)
		{
			BaseRecord record = currentNode.AssociatedObject;

			if (record.GetType() == typeof(FolderRecord))
			{
				FolderRecord folderRecord = (FolderRecord)record;
				var folder = CreateFolder(groupAddTo, folderRecord);

				foreach (var node in currentNode.Nodes)
				{
					ImportRecord(node, folder, pwStorage);
				}
			}
			else if (record.GetType() == typeof(WebFormRecord))
			{
				WebFormRecord webForm = (WebFormRecord)record;
				CreateWebForm(groupAddTo, pwStorage, webForm);
			}
			else if (record.GetType() == typeof(BaseRecord))
			{
				//Trace.WriteLine(String.Format("Error. Can't import unknown record type: {0}", record.RawJson));
			}
			else if (record.GetType() == typeof(UnknownRecord))
			{
				//CreateUnknown(groupAddTo, pwStorage, record as UnknownRecord);
			}
		}
开发者ID:diimdeep,项目名称:1P2KeePass,代码行数:28,代码来源:PIFImporter.cs


示例4: ProcessCsvLine

		private static void ProcessCsvLine(string strLine, PwDatabase pwStorage)
		{
			List<string> list = ImportUtil.SplitCsvLine(strLine, ",");
			Debug.Assert(list.Count == 5);

			PwEntry pe = new PwEntry(true, true);
			pwStorage.RootGroup.AddEntry(pe, true);

			if(list.Count == 5)
			{
				pe.Strings.Set(PwDefs.TitleField, new ProtectedString(
					pwStorage.MemoryProtection.ProtectTitle,
					ProcessCsvWord(list[0])));
				pe.Strings.Set(PwDefs.UserNameField, new ProtectedString(
					pwStorage.MemoryProtection.ProtectUserName,
					ProcessCsvWord(list[1])));
				pe.Strings.Set(PwDefs.PasswordField, new ProtectedString(
					pwStorage.MemoryProtection.ProtectPassword,
					ProcessCsvWord(list[2])));
				pe.Strings.Set(PwDefs.UrlField, new ProtectedString(
					pwStorage.MemoryProtection.ProtectUrl,
					ProcessCsvWord(list[3])));
				pe.Strings.Set(PwDefs.NotesField, new ProtectedString(
					pwStorage.MemoryProtection.ProtectNotes,
					ProcessCsvWord(list[4])));
			}
			else throw new FormatException("Invalid field count!");
		}
开发者ID:ComradeP,项目名称:KeePass-2.x,代码行数:28,代码来源:PwKeeperCsv70.cs


示例5: InitEx

        public void InitEx(bool bCreatingNew, PwDatabase pwDatabase)
        {
            m_bCreatingNew = bCreatingNew;

            Debug.Assert(pwDatabase != null); if(pwDatabase == null) throw new ArgumentNullException("pwDatabase");
            m_pwDatabase = pwDatabase;
        }
开发者ID:amiryal,项目名称:keepass2,代码行数:7,代码来源:DatabaseSettingsForm.cs


示例6: Main

    public static void Main(string[] args)
    {
        CompositeKey key = new CompositeKey();
        KcpPassword pw = new KcpPassword("12345");
        key.AddUserKey(pw);
        byte[] pwdata = pw.KeyData.ReadData();
        Console.WriteLine("PW data:");
        Console.WriteLine(string.Join(",", pwdata.Select(x => "0x" + x.ToString("x"))));
        byte[] keydata = key.GenerateKey32(pwdata, 6000).ReadData();
        Console.WriteLine("Key data:");
        Console.WriteLine(string.Join(",", keydata.Select(x => "0x" + x.ToString("x"))));

        PwDatabase db = new PwDatabase();
        db.MasterKey = key;
        KdbxFile kdbx = new KdbxFile(db);
        kdbx.Load(@"..\resources\test.kdbx", KdbxFormat.Default, null);

        var groups = db.RootGroup.GetGroups(true);
        Console.WriteLine("Group count: " + groups.UCount);
        var entries = db.RootGroup.GetEntries(true);
        Console.WriteLine("Entry count: " + entries.UCount);

        CompositeKey key2 = new CompositeKey();
        key2.AddUserKey(pw);
        KcpKeyFile keyfile = new KcpKeyFile(@"..\resources\keyfile.key");
        key2.AddUserKey(keyfile);
        byte[] keyfiledata = keyfile.KeyData.ReadData();
        Console.WriteLine("Key file data:");
        Console.WriteLine(string.Join(",", keyfiledata.Select(x => "0x" + x.ToString("x"))));
        Console.WriteLine("Composite Key data:");
        byte[] key2data = key2.GenerateKey32(keyfiledata, 6000).ReadData();
        Console.WriteLine(string.Join(",", key2data.Select(x => "0x" + x.ToString("x"))));
    }
开发者ID:jdonofrio728,项目名称:keepassj,代码行数:33,代码来源:test.cs


示例7: Copy

		public static bool Copy(ProtectedString psToCopy, bool bIsEntryInfo,
			PwEntry peEntryInfo, PwDatabase pwReferenceSource)
		{
			Debug.Assert(psToCopy != null);
			if(psToCopy == null) throw new ArgumentNullException("psToCopy");

			if(bIsEntryInfo && !AppPolicy.Try(AppPolicyId.CopyToClipboard))
				return false;

			string strData = SprEngine.Compile(psToCopy.ReadString(), false,
				peEntryInfo, pwReferenceSource, false, false);

			try
			{
				ClipboardUtil.Clear();

				DataObject doData = CreateProtectedDataObject(strData);
				Clipboard.SetDataObject(doData);

				m_pbDataHash32 = HashClipboard();
				m_strFormat = null;

				RaiseCopyEvent(bIsEntryInfo, strData);
			}
			catch(Exception) { Debug.Assert(false); return false; }

			if(peEntryInfo != null) peEntryInfo.Touch(false);

			// SprEngine.Compile might have modified the database
			Program.MainForm.UpdateUI(false, null, false, null, false, null, false);

			return true;
		}
开发者ID:ComradeP,项目名称:KeePass-2.x,代码行数:33,代码来源:ClipboardUtil.cs


示例8: Import

		public override void Import(PwDatabase pwStorage, Stream sInput,
			IStatusLogger slLogger)
		{
			XmlDocument xmlDoc = new XmlDocument();
			xmlDoc.Load(sInput);

			XmlNode xmlRoot = xmlDoc.DocumentElement;
			Debug.Assert(xmlRoot.Name == ElemRoot);

			Stack<PwGroup> vGroups = new Stack<PwGroup>();
			vGroups.Push(pwStorage.RootGroup);

			int nNodeCount = xmlRoot.ChildNodes.Count;
			for(int i = 0; i < nNodeCount; ++i)
			{
				XmlNode xmlChild = xmlRoot.ChildNodes[i];

				if(xmlChild.Name == ElemGroup)
					ReadGroup(xmlChild, vGroups, pwStorage);
				else { Debug.Assert(false); }

				if(slLogger != null)
					slLogger.SetProgress((uint)(((i + 1) * 100) / nNodeCount));
			}
		}
开发者ID:ComradeP,项目名称:KeePass-2.x,代码行数:25,代码来源:KeePassXXml041.cs


示例9: Copy

        public static bool Copy(string strToCopy, bool bIsEntryInfo,
            PwEntry peEntryInfo, PwDatabase pwReferenceSource)
        {
            Debug.Assert(strToCopy != null);
            if(strToCopy == null) throw new ArgumentNullException("strToCopy");

            if(bIsEntryInfo && !AppPolicy.Try(AppPolicyId.CopyToClipboard))
                return false;

            string strData = SprEngine.Compile(strToCopy, false, peEntryInfo,
                pwReferenceSource, false, false);

            try
            {
                Clipboard.Clear();

                DataObject doData = CreateProtectedDataObject(strData);
                Clipboard.SetDataObject(doData);

                m_pbDataHash32 = HashClipboard();
                m_strFormat = null;
            }
            catch(Exception) { Debug.Assert(false); return false; }

            return true;
        }
开发者ID:jonbws,项目名称:strengthreport,代码行数:26,代码来源:ClipboardUtil.cs


示例10: SetEntry

                public void SetEntry(PwEntry e)
                {
                    KpDatabase = new PwDatabase();
                    KpDatabase.New(new IOConnectionInfo(), new CompositeKey());

                    KpDatabase.RootGroup.AddEntry(e, true);
                }
开发者ID:pythe,项目名称:wristpass,代码行数:7,代码来源:App.cs


示例11: Synchronize

		public static bool? Synchronize(PwDatabase pwStorage, IUIOperations uiOps,
			bool bOpenFromUrl, Form fParent)
		{
			if(pwStorage == null) throw new ArgumentNullException("pwStorage");
			if(!pwStorage.IsOpen) return null;
			if(!AppPolicy.Try(AppPolicyId.Import)) return null;

			List<IOConnectionInfo> vConnections = new List<IOConnectionInfo>();
			if(bOpenFromUrl == false)
			{
				OpenFileDialog ofd = UIUtil.CreateOpenFileDialog(KPRes.Synchronize,
					UIUtil.CreateFileTypeFilter(null, null, true), 1, null, true, true);

				if(ofd.ShowDialog() != DialogResult.OK) return null;

				foreach(string strSelFile in ofd.FileNames)
					vConnections.Add(IOConnectionInfo.FromPath(strSelFile));
			}
			else // Open URL
			{
				IOConnectionForm iocf = new IOConnectionForm();
				iocf.InitEx(false, new IOConnectionInfo(), true, true);

				if(iocf.ShowDialog() != DialogResult.OK) return null;

				vConnections.Add(iocf.IOConnectionInfo);
			}

			return Import(pwStorage, new KeePassKdb2x(), vConnections.ToArray(),
				true, uiOps, false, fParent);
		}
开发者ID:ComradeP,项目名称:KeePass-2.x,代码行数:31,代码来源:ImportUtil.cs


示例12: Import

		public override void Import(PwDatabase pwStorage, Stream sInput,
			IStatusLogger slLogger)
		{
			StreamReader sr = new StreamReader(sInput, StrUtil.Utf8);
			string strDoc = sr.ReadToEnd();
			sr.Close();

			XmlDocument doc = new XmlDocument();
			doc.LoadXml(strDoc);

			XmlElement xmlRoot = doc.DocumentElement;
			Debug.Assert(xmlRoot.Name == ElemRoot);

			PwGroup pgRoot = pwStorage.RootGroup;

			foreach(XmlNode xmlChild in xmlRoot.ChildNodes)
			{
				if(xmlChild.Name == ElemGroup)
					ImportGroup(xmlChild, pgRoot, pwStorage, false);
				else if(xmlChild.Name == ElemRecycleBin)
					ImportGroup(xmlChild, pgRoot, pwStorage, true);
				else if(xmlChild.Name == ElemEntry)
					ImportEntry(xmlChild, pgRoot, pwStorage);
				else { Debug.Assert(false); }
			}
		}
开发者ID:joshuadugie,项目名称:KeePass-2.x,代码行数:26,代码来源:PwSaverXml412.cs


示例13: Import

 /// <summary>
 /// The function tries to merge possible updates from the deltaDB into
 /// the actual database. If there was made changes to the actualDB, then
 /// the function fires a event, which cause the KeePass UI to update and
 /// show the "save"-button.
 /// </summary>
 public void Import(object sender, SyncSource source)
 {
     Debug.Assert(source.DestinationDB != null && source.DestinationDB.RootGroup != null);
     //merge all updates in
     PwDatabase deltaDB = new PwDatabase();
     try
     {
         deltaDB.Open(IOConnectionInfo.FromPath(source.Location), source.Key, null);
     }
     catch (InvalidCompositeKeyException e)
     {
         Debug.WriteLine("Wrong key! exception was: " + e.Message);
         //brand this entry as a false one => red bg-color and "X" as group icon
         ShowErrorHighlight(source.DestinationDB, source.Uuid);
         if (Imported != null) Imported.Invoke(this, source.DestinationDB.RootGroup);
         return;
     }
     catch (Exception e)
     {
         Debug.WriteLine("Standard exception was thrown during deltaDB.Open(): " + e.Message);
         //maybe the process has not finished writing to our file, but the filewtcher fires our event
         //sourceEntryUuid we have to ignore it and wait for the next one.
         return;
     }
     HideErrorHighlight(source.DestinationDB, source.Uuid);
     MergeIn(source.DestinationDB, deltaDB);
     deltaDB.Close();
 }
开发者ID:hicknhack-software,项目名称:KeeShare,代码行数:34,代码来源:SyncImporter.cs


示例14: ImportEntry

		private static void ImportEntry(XmlNode xmlNode, PwDatabase pwStorage,
			Dictionary<string, PwGroup> dGroups)
		{
			PwEntry pe = new PwEntry(true, true);
			string strGroup = string.Empty;

			foreach(XmlNode xmlChild in xmlNode)
			{
				string strInner = XmlUtil.SafeInnerText(xmlChild);

				if(xmlChild.Name == ElemCategory)
					strGroup = strInner;
				else if(xmlChild.Name == ElemTitle)
					pe.Strings.Set(PwDefs.TitleField, new ProtectedString(
						pwStorage.MemoryProtection.ProtectTitle, strInner));
				else if(xmlChild.Name == ElemNotes)
					pe.Strings.Set(PwDefs.NotesField, new ProtectedString(
						pwStorage.MemoryProtection.ProtectNotes, strInner));
			}

			PwGroup pg;
			dGroups.TryGetValue(strGroup, out pg);
			if(pg == null)
			{
				pg = new PwGroup(true, true);
				pg.Name = strGroup;
				dGroups[string.Empty].AddGroup(pg, true);
				dGroups[strGroup] = pg;
			}
			pg.AddEntry(pe, true);
		}
开发者ID:dbremner,项目名称:keepass2,代码行数:31,代码来源:DesktopKnox32.cs


示例15: CreateAndSaveLocal

        public void CreateAndSaveLocal()
        {
            IKp2aApp app = new TestKp2aApp();
            IOConnectionInfo ioc = new IOConnectionInfo {Path = DefaultFilename};

            File outputDir = new File(DefaultDirectory);
            outputDir.Mkdirs();
            File targetFile = new File(ioc.Path);
            if (targetFile.Exists())
                targetFile.Delete();

            bool createSuccesful = false;
            //create the task:
            CreateDb createDb = new CreateDb(app, Application.Context, ioc, new ActionOnFinish((success, message) =>
                { createSuccesful = success;
                    if (!success)
                        Android.Util.Log.Debug("KP2A_Test", message);
                }), false);
            //run it:

            createDb.Run();
            //check expectations:
            Assert.IsTrue(createSuccesful);
            Assert.IsNotNull(app.GetDb());
            Assert.IsNotNull(app.GetDb().KpDatabase);
            //the create task should create two groups:
            Assert.AreEqual(2, app.GetDb().KpDatabase.RootGroup.Groups.Count());

            //ensure the the database can be loaded from file:
            PwDatabase loadedDb = new PwDatabase();
            loadedDb.Open(ioc, new CompositeKey(), null, new KdbxDatabaseFormat(KdbxFormat.Default));

            //Check whether the databases are equal
            AssertDatabasesAreEqual(loadedDb, app.GetDb().KpDatabase);
        }
开发者ID:pythe,项目名称:wristpass,代码行数:35,代码来源:TestCreateDb.cs


示例16: TestCreateSaveAndLoad_TestIdenticalFiles_kdb

        public void TestCreateSaveAndLoad_TestIdenticalFiles_kdb()
        {
            string filename = DefaultDirectory + "createsaveandload.kdb";
            IKp2aApp app = SetupAppWithDatabase(filename);
            string kdbxXml = DatabaseToXml(app);
            //save it and reload it
            Android.Util.Log.Debug("KP2A", "-- Save DB -- ");
            SaveDatabase(app);
            Android.Util.Log.Debug("KP2A", "-- Load DB -- ");

            PwDatabase pwImp = new PwDatabase();
            PwDatabase pwDatabase = app.GetDb().KpDatabase;
            pwImp.New(new IOConnectionInfo(), pwDatabase.MasterKey);
            pwImp.MemoryProtection = pwDatabase.MemoryProtection.CloneDeep();
            pwImp.MasterKey = pwDatabase.MasterKey;

            IOConnectionInfo ioc = new IOConnectionInfo() {Path = filename};
            using (Stream s = app.GetFileStorage(ioc).OpenFileForRead(ioc))
            {
                app.GetDb().DatabaseFormat.PopulateDatabaseFromStream(pwImp, s, null);
            }
            string kdbxReloadedXml = DatabaseToXml(app);

            RemoveKdbLines(ref kdbxReloadedXml);
            RemoveKdbLines(ref kdbxXml);

            Assert.AreEqual(kdbxXml, kdbxReloadedXml);
        }
开发者ID:pythe,项目名称:wristpass,代码行数:28,代码来源:TestSaveDb.cs


示例17: ApplyTo

        // public bool CopyHistory
        // {
        //    get { return m_bCopyHistory; }
        // }
        public void ApplyTo(PwEntry peNew, PwEntry pe, PwDatabase pd)
        {
            if((peNew == null) || (pe == null)) { Debug.Assert(false); return; }

            Debug.Assert(peNew.Strings.ReadSafe(PwDefs.UserNameField) ==
                pe.Strings.ReadSafe(PwDefs.UserNameField));
            Debug.Assert(peNew.Strings.ReadSafe(PwDefs.PasswordField) ==
                pe.Strings.ReadSafe(PwDefs.PasswordField));

            if(m_bAppendCopy && (pd != null))
            {
                string strTitle = peNew.Strings.ReadSafe(PwDefs.TitleField);
                peNew.Strings.Set(PwDefs.TitleField, new ProtectedString(
                    pd.MemoryProtection.ProtectTitle, strTitle + " - " +
                    KPRes.CopyOfItem));
            }

            if(m_bFieldRefs && (pd != null))
            {
                string strUser = @"{REF:[email protected]:" + pe.Uuid.ToHexString() + @"}";
                peNew.Strings.Set(PwDefs.UserNameField, new ProtectedString(
                    pd.MemoryProtection.ProtectUserName, strUser));

                string strPw = @"{REF:[email protected]:" + pe.Uuid.ToHexString() + @"}";
                peNew.Strings.Set(PwDefs.PasswordField, new ProtectedString(
                    pd.MemoryProtection.ProtectPassword, strPw));
            }

            if(!m_bCopyHistory)
                peNew.History = new PwObjectList<PwEntry>();
        }
开发者ID:haro-freezd,项目名称:KeePass,代码行数:35,代码来源:DuplicationForm.cs


示例18: GetIconDrawable

 public Drawable GetIconDrawable(Resources res, PwDatabase db, PwIcon icon, PwUuid customIconId)
 {
     if (!customIconId.Equals(PwUuid.Zero)) {
         return GetIconDrawable (res, db, customIconId);
     }
     return GetIconDrawable (res, icon);
 }
开发者ID:pythe,项目名称:wristpass,代码行数:7,代码来源:DrawableFactory.cs


示例19: InitEx

        public void InitEx(PwGroup pg, bool bCreatingNew, ImageList ilClientIcons,
			PwDatabase pwDatabase)
        {
            m_pwGroup = pg;
            m_bCreatingNew = bCreatingNew;
            m_ilClientIcons = ilClientIcons;
            m_pwDatabase = pwDatabase;
        }
开发者ID:haro-freezd,项目名称:KeePass,代码行数:8,代码来源:GroupForm.cs


示例20: KdbFile

		/// <summary>
		/// Default constructor.
		/// </summary>
		/// <param name="pwDataStore">The <c>PwDatabase</c> instance that the class
		/// will load file data into or use to create a KDB file. Must not be <c>null</c>.</param>
		/// <exception cref="System.ArgumentNullException">Thrown if the database
		/// reference is <c>null</c>.</exception>
		public KdbFile(PwDatabase pwDataStore, IStatusLogger slLogger)
		{
			Debug.Assert(pwDataStore != null);
			if(pwDataStore == null) throw new ArgumentNullException("pwDataStore");
			m_pwDatabase = pwDataStore;

			m_slLogger = slLogger;
		}
开发者ID:kusuriya,项目名称:PasswordKeeper,代码行数:15,代码来源:KdbFile.cs



注:本文中的KeePassLib.PwDatabase类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# KeePassLib.PwUuid类代码示例发布时间:2022-05-26
下一篇:
C# KeePassHttp.Request类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap