Giter Site home page Giter Site logo

Comments (4)

RiggerJay avatar RiggerJay commented on June 15, 2024

I guess never mind... this was meant for ModernKeypassLib

from modernkeepass.

wismna avatar wismna commented on June 15, 2024

Hi,

I work on both, so don't worry. I will create a Readme file on the ModernKeePassLib project explaining how to use it. I agree it's not as easy as it looks, because I tried to do minimal changes in the original code, so the workflow can be a bit twisted.
The thing is, you can't use a file path to create a IOConnectionInfo. Instead, IOConnectionInfo requires a byte array, like so:

var ioConnection = IOConnectionInfo.FromByteArray(byte_array);

Then you can open your database.
(I did this to remove the dependency on the file system.)

from modernkeepass.

wismna avatar wismna commented on June 15, 2024

Hi,

I updated the readme to give info on how to use the library.
Please let me know if this works for you.
Readme

from modernkeepass.

suanmb avatar suanmb commented on June 15, 2024

`var dbpath = @"c:\Database2.kdbx";
//var keypath = @"\xxx\Desktop\KeePassDatabase\Database.key";
var masterpw = "123456";

var ioConnInfo = IOConnectionInfo.FromByteArray(File.ReadAllBytes(dbpath));
var compKey = new CompositeKey();
compKey.AddUserKey(new KcpPassword(masterpw));
//compKey.AddUserKey(new KcpKeyFile(IOConnectionInfo.FromPath(keypath)));

var db = new PwDatabase();
db.Open(ioConnInfo, compKey, new NullStatusLogger());

//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"),
// };

//Console.WriteLine(string.Join(Environment.NewLine, kpdata));
db.Close();`

I used the above code, but why would it give me this error?

未经处理的异常: System.InvalidOperationException: 节点类型 Attribute 上不支持 ReadElementContentAsString 方法。 行 34,位置 19。
在 System.Xml.XmlReader.SetupReadElementContentAsXxx(String methodName)
在 System.Xml.XmlReader.ReadElementContentAsString()
在 ModernKeePassLib.Serialization.KdbxFile.ReadBase64(XmlReader xr, Boolean bRaw)
在 ModernKeePassLib.Serialization.KdbxFile.ReadProtectedBinary(XmlReader xr)
在 ModernKeePassLib.Serialization.KdbxFile.ReadXmlElement(KdbContext ctx, XmlReader xr)
在 ModernKeePassLib.Serialization.KdbxFile.ReadDocumentStreamed(XmlReader xr, Stream sParentStream)
在 ModernKeePassLib.Serialization.KdbxFile.ReadXmlStreamed(Stream sXml, Stream sParent)
在 ModernKeePassLib.Serialization.KdbxFile.Load(Stream sSource, KdbxFormat fmt, IStatusLogger slLogger)
在 ModernKeePassLib.PwDatabase.Open(IOConnectionInfo ioSource, CompositeKey pwKey, IStatusLogger slLogger)
在 ConsoleApp1.Program.Main(String[] args) 位置 C:\Users\ygct\source\repos\ConsoleApp1\ConsoleApp1\Program.cs:行号 28请按任意键继 续. . .

from modernkeepass.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.