mirror of
https://github.com/wismna/ModernKeePassLib.git
synced 2025-10-03 07:30:16 -04:00
Populated readme file
Removed version check for XML writes
This commit is contained in:
@@ -17,8 +17,6 @@
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Splat" Version="3.0.0" />
|
||||
<PackageReference Include="System.Runtime.WindowsRuntime" Version="4.7.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@@ -7,6 +7,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModernKeePassLib.Test", "Mo
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModernKeePassLib", "ModernKeePassLib\ModernKeePassLib.csproj", "{85C3EA08-C9C4-4A8E-AB52-BE8A6475B787}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2390E567-E65A-43C1-9D07-6680296D1BE0}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.gitignore = .gitignore
|
||||
README.md = README.md
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard1.2</TargetFramework>
|
||||
<Description>Portable KeePass Password Management Library that targets .Net Standard and WinRT. Allows reading, editing and writing to KeePass 2.x databases.</Description>
|
||||
<Version>2.44.2</Version>
|
||||
<Version>2.44.3</Version>
|
||||
<Authors>Geoffroy Bonneville</Authors>
|
||||
<Company>wismna</Company>
|
||||
<PackageProjectUrl>https://github.com/wismna/ModernKeePass</PackageProjectUrl>
|
||||
@@ -55,7 +55,7 @@
|
||||
<PackageReference Include="Portable.BouncyCastle" Version="1.8.5" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.0-beta0005" />
|
||||
<PackageReference Include="Splat" Version="3.0.0" />
|
||||
<PackageReference Include="System.Runtime.WindowsRuntime" Version="4.3.0" />
|
||||
<PackageReference Include="System.Runtime.WindowsRuntime" Version="4.7.0" />
|
||||
<PackageReference Include="System.Xml.XmlSerializer" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@@ -204,7 +204,7 @@ namespace ModernKeePassLib.Serialization
|
||||
throw new ArgumentOutOfRangeException("fmt");
|
||||
}
|
||||
|
||||
m_xmlWriter = XmlUtilEx.CreateXmlWriter(sXml, m_uFileVersion >= FileVersion32_4);
|
||||
m_xmlWriter = XmlUtilEx.CreateXmlWriter(sXml);
|
||||
|
||||
WriteDocument(pgRoot);
|
||||
|
||||
|
@@ -74,28 +74,24 @@ namespace ModernKeePassLib.Utility
|
||||
return XmlReader.Create(s, CreateXmlReaderSettings());
|
||||
}
|
||||
|
||||
public static XmlWriterSettings CreateXmlWriterSettings(bool isVersionGreaterThan4 = false)
|
||||
public static XmlWriterSettings CreateXmlWriterSettings()
|
||||
{
|
||||
XmlWriterSettings xws = new XmlWriterSettings();
|
||||
|
||||
xws.CloseOutput = isVersionGreaterThan4;
|
||||
xws.CloseOutput = false;
|
||||
xws.Encoding = StrUtil.Utf8;
|
||||
xws.Indent = true;
|
||||
xws.IndentChars = "\t";
|
||||
xws.NewLineOnAttributes = false;
|
||||
#if ModernKeePassLib
|
||||
// This is needed for Argon2Kdf write
|
||||
xws.Async = true;
|
||||
#endif
|
||||
|
||||
return xws;
|
||||
}
|
||||
|
||||
public static XmlWriter CreateXmlWriter(Stream s, bool isVersionGreaterThan4 = false)
|
||||
public static XmlWriter CreateXmlWriter(Stream s)
|
||||
{
|
||||
if(s == null) { Debug.Assert(false); throw new ArgumentNullException("s"); }
|
||||
|
||||
return XmlWriter.Create(s, CreateXmlWriterSettings(isVersionGreaterThan4));
|
||||
return XmlWriter.Create(s, CreateXmlWriterSettings());
|
||||
}
|
||||
|
||||
public static void Serialize<T>(Stream s, T t)
|
||||
|
29
README.md
29
README.md
@@ -1,3 +1,32 @@
|
||||
## ModernKeePassLib
|
||||
|
||||
[](https://dev.azure.com/geogeob/ModernKeePass/_build/latest?definitionId=6)
|
||||
|
||||
# What is this ?
|
||||
|
||||
ModernKeePassLib is a port of KeePassLib to .netstandard 1.2, distributed as a nuget package.
|
||||
The aim was to change as little as possible the original library. However, some workarounds have to be made as .netstandard misses quite a few features of the full .net framework.
|
||||
Main changes:
|
||||
- Removed the dependency on the filesystem
|
||||
- Added a dependency on Windows (I'm working on tring to find a way to remove it altogether)
|
||||
- Some features are handled by external nuget packages (cryptography, colors, etc.), so it may introduce small differences
|
||||
|
||||
# Usage
|
||||
|
||||
1. Create a IOConnectionInfo from a byte array:
|
||||
`var ioConnection = IOConnectionInfo.FromByteArray(file);`
|
||||
2. Create a composite key and add credential information:
|
||||
`var compositeKey = new CompositeKey();
|
||||
// Password
|
||||
compositeKey.AddUserKey(new KcpPassword("Password"));`
|
||||
// Key file
|
||||
compositeKey.AddUserKey(new KcpKeyFile(IOConnectionInfo.FromByteArray(KeyFileContents)));`
|
||||
3. Use it to open the database:
|
||||
// You may use whatever logger you choose (here, I use nullstatuslogger)
|
||||
`PwDatabase.Open(ioConnection, compositeKey, new NullStatusLogger());`
|
||||
4. Do stuff in you database (create entries, groups, ...)
|
||||
5. Save your changes:
|
||||
`PwDatabase.Save(new NullStatusLogger());`
|
||||
6. At this point, nothing is commited to disk, so you need to retrieve the byte array:
|
||||
`var contents = PwDatabase.IOConnectionInfo.Bytes;`
|
||||
7. Write the byte array to a file, to a stream, whatever !
|
Reference in New Issue
Block a user