存储从C#的KeePass数据库中的敏感信息 [英] Store sensitive information inside keepass database from c#
本文介绍了存储从C#的KeePass数据库中的敏感信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个项目,我必须处理敏感数据。
你知道如何打开一个数据库KeePass的形式C#中使用DATAS?
I have a project where I have to handle sensitive data. Do you know how to open a keepass database form c# to use the datas ?
我已经下载了来源。我会看它TE得到我所需要的。任何其他的想法?
I have downloaded the sources. I will look in it te get what I need. any other idea?
推荐答案
我想过读的keypass 2数据库,所以我加入到Linqpad一个KeyPass.exe参考,并开始实验。令我惊讶的,没有任何外界帮助(证明了一个好的API),我只是几分钟后读取数据库。以下是我做的:
I thought about reading a KeyPass 2 database so I added a reference to KeyPass.exe in Linqpad and started to experiment. To my surprise and without any outside help (a testament to a good API), I was reading the database after only a few minutes. Here's how I did it:
var dbpath = @"C:\path\to\passwords.kdbx";
var masterpw = "Your$uper$tr0ngMst3rP@ssw0rd";
var ioConnInfo = new IOConnectionInfo { Path = dbpath };
var compKey = new CompositeKey();
compKey.AddUserKey(new KcpPassword(masterpw));
var db = new KeePassLib.PwDatabase();
db.Open(ioConnInfo, compKey, null);
var kpdata = from entry in db.RootGroup.GetEntries(true)
select new
{
Group = entry.ParentGroup.Name,
Title = entry.Strings.ReadSafe("Title"),
Username = entry.Strings.ReadSafe("UserName"),
Password = entry.Strings.ReadSafe("Password"),
URL = entry.Strings.ReadSafe("URL"),
Notes = entry.Strings.ReadSafe("Notes")
};
kpdata.Dump(); // this is how Linqpad outputs stuff
db.Close();
这篇关于存储从C#的KeePass数据库中的敏感信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文