Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
JanisEst committed May 6, 2016
1 parent 18671b3 commit 6a21323
Show file tree
Hide file tree
Showing 10 changed files with 456 additions and 0 deletions.
76 changes: 76 additions & 0 deletions KeePassNewKeyExport.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{6A249FA1-3F87-4C81-8D31-6BDF62308F38}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>KeePassNewKeyExport</RootNamespace>
<AssemblyName>KeePassNewKeyExport</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="KeePass, Version=2.31.0.34650, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>.\KeePass.exe</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Compile Include="KeePassNewKeyExportExt.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="NewKeyKdb2x.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="keepass.version" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\B16x16_KeePassPlus.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
22 changes: 22 additions & 0 deletions KeePassNewKeyExport.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KeePassNewKeyExport", "KeePassNewKeyExport.csproj", "{6A249FA1-3F87-4C81-8D31-6BDF62308F38}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6A249FA1-3F87-4C81-8D31-6BDF62308F38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6A249FA1-3F87-4C81-8D31-6BDF62308F38}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6A249FA1-3F87-4C81-8D31-6BDF62308F38}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6A249FA1-3F87-4C81-8D31-6BDF62308F38}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
29 changes: 29 additions & 0 deletions KeePassNewKeyExportExt.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System.Diagnostics.Contracts;
using System.Drawing;

using KeePass.Plugins;

namespace KeePassNewKeyExport
{
public class KeePassNewKeyExportExt : Plugin
{
public override Image SmallIcon
{
get { return Properties.Resources.B16x16_KeePassPlus; }
}

public override string UpdateUrl
{
get { return "https://github.com/KN4CK3R/KeePassNewKeyExport/raw/master/keepass.version"; }
}

public override bool Initialize(IPluginHost host)
{
Contract.Requires(host != null);

host.FileFormatPool.Add(new NewKeyKdb2x());

return true;
}
}
}
78 changes: 78 additions & 0 deletions NewKeyKdb2x.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using KeePass.App;
using KeePass.DataExchange;
using KeePass.Forms;
using KeePassLib;
using KeePassLib.Interfaces;
using KeePassLib.Serialization;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Windows.Forms;

namespace KeePassNewKeyExport
{
internal sealed class NewKeyKdb2x : FileFormatProvider
{
public override bool SupportsImport { get { return false; } }
public override bool SupportsExport { get { return true; } }

public override string FormatName { get { return "KeePass KDBX (2.x) with new Password"; } }
public override string DefaultExtension { get { return AppDefs.FileExtension.FileExt; } }
public override string ApplicationGroup { get { return PwDefs.ShortProductName; } }

public override Image SmallIcon
{
get { return Properties.Resources.B16x16_KeePassPlus; }
}

public override bool Export(PwExportInfo pwExportInfo, Stream sOutput,
IStatusLogger slLogger)
{
//Debugger.Launch();

//ask for the database key
KeyCreationForm kcf = new KeyCreationForm();
DialogResult dr = kcf.ShowDialog();
if (dr == DialogResult.Cancel || dr == DialogResult.Abort)
{
return false;
}

PwDatabase pd = new PwDatabase();
pd.New(new IOConnectionInfo(), kcf.CompositeKey);

//get used custom icons
pwExportInfo.DataGroup.TraverseTree(
TraversalMethod.PreOrder,
null,
e =>
{
if (!e.CustomIconUuid.Equals(PwUuid.Zero))
{
pd.CustomIcons.AddRange(pwExportInfo.ContextDatabase.CustomIcons.Where(i => i.Uuid.Equals(e.CustomIconUuid)));
}

return true;
}
);

//get other database settings
DatabaseSettingsForm dsf = new DatabaseSettingsForm();
dsf.InitEx(true, pd);
dr = dsf.ShowDialog();
if (dr == DialogResult.Cancel || dr == DialogResult.Abort)
{
pd.Close();

return false;
}

//and save the new database
KdbxFile kdbx = new KdbxFile(pd);
kdbx.Save(sOutput, pwExportInfo.DataGroup, KdbxFormat.Default, slLogger);

return true;
}
}
}
36 changes: 36 additions & 0 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die einer Assembly zugeordnet sind.
[assembly: AssemblyTitle("KeePassNewKeyExport")]
[assembly: AssemblyDescription("KeePass 2.x plugin which exports entries with a new password.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Janis Estelmann")]
[assembly: AssemblyProduct("KeePass Plugin")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
[assembly: ComVisible(false)]

// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("6a249fa1-3f87-4c81-8d31-6bdf62308f39")]

// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
73 changes: 73 additions & 0 deletions Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6a21323

Please sign in to comment.