Skip to content

Commit

Permalink
Merge pull request #2 from VictorGrycuk/dev/1.2
Browse files Browse the repository at this point in the history
[1.2] Add option to exclude characters and custom pattern for password generation action
  • Loading branch information
VictorGrycuk authored Aug 19, 2020
2 parents dbbc2f0 + 2d8b80c commit 256f30b
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 8 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ It uses the following configuration:
- **Use Special Characters.** ``!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~``. Default `true`.
- **Exclude Look-Alike characters.** It will avoid using two character that look similar, like `O` and `0`. Default `false`.
- **Must occur at most Once.** It will prevent characters from appearing more than once. Default `false`.
- **Characters to Exclude.** Any character included in the text field will be excluded from the generated password.
- **Custom Pattern.** Allows to use a custom defined password generation pattern. Refer to the section *Generating Passwords that Follow Rules* of [KeePass Password Generator](https://keepass.info/help/base/pwgenerator.html) documentation.
- ***Note***: Using a custom pattern will override all the previous configuration.

Check [KeePass Password Generator](https://keepass.info/help/base/pwgenerator.html) help site for more information.

Expand Down
23 changes: 18 additions & 5 deletions StreamDeck-KeePass/StreamDeck-KeePass/KeePassGenerate.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
using BarRaider.SdTools;
using KeePassLib.Cryptography.PasswordGenerator;
using KeePassLib.Keys;
using KeePassLib.Security;
using KeePassLib.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using streamdeck_keepass;
using System;
using System.Linq;
using System.Threading.Tasks;

namespace StreamDeck_KeePass
Expand All @@ -27,7 +24,9 @@ public static PluginSettings CreateDefaultSettings()
UseDigits = true,
UsePunctuation = true,
UseBrackets = true,
UseSpecial = true
UseSpecial = true,
ExcludeCharacters = string.Empty,
CustomPattern = string.Empty
};
return instance;
}
Expand Down Expand Up @@ -58,6 +57,12 @@ public static PluginSettings CreateDefaultSettings()

[JsonProperty(PropertyName = "mustOccurAtMostOnce")]
public bool MustOccurAtMostOnce { get; set; }

[JsonProperty(PropertyName = "excludeCharacters")]
public string ExcludeCharacters { get; set; }

[JsonProperty(PropertyName = "customPattern")]
public string CustomPattern { get; set; }
}

#region Private Members
Expand Down Expand Up @@ -101,7 +106,15 @@ public override void KeyPressed(KeyPayload payload)
profile.ExcludeLookAlike = settings.ExcludeLookAlike;
profile.Length = (uint)settings.Length;
profile.NoRepeatingCharacters = settings.MustOccurAtMostOnce;

profile.ExcludeCharacters = settings.ExcludeCharacters;

if (!string.IsNullOrEmpty(settings.CustomPattern))
{
profile.GeneratorType = PasswordGeneratorType.Pattern;
profile.PatternPermutePassword = true;
profile.Pattern = settings.CustomPattern;
}

PwGenerator.Generate(out pw, profile, null, new CustomPwGeneratorPool());

if (pw.IsEmpty)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@
</div>
</div>
</div>
<div class="sdpi-item" id="dvExcludeCharacters">
<div class="sdpi-item-label">Characters to Exclude</div>
<input class="sdpi-item-value sdProperty" id="excludeCharacters" oninput="setSettings()">
</div>
<div class="sdpi-item" id="dvCustomPattern">
<div class="sdpi-item-label">Custom Pattern</div>
<input class="sdpi-item-value sdProperty" id="customPattern" oninput="setSettings()">
</div>
</div>
</body>
</html>
29 changes: 28 additions & 1 deletion StreamDeck-KeePass/StreamDeck-KeePass/StreamDeck-KeePass.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -27,7 +42,7 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\StreamDeck_KeePass.sdPlugin\</OutputPath>
<OutputPath>bin\Release\com.victorgrycuk.keepass.sdPlugin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand Down Expand Up @@ -152,6 +167,18 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.7.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.7.2 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>$(ProjectDir)\..\..\Tools\DistributionTool.exe -b -i $(ProjectDir)\$(OutDir) -o $(ProjectDir)\$(OutDir)
Expand Down
4 changes: 2 additions & 2 deletions StreamDeck-KeePass/StreamDeck-KeePass/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"FontSize": "12"
}
],
"SupportedInMultiActions": false,
"SupportedInMultiActions": true,
"Tooltip": "Generates a custom password using Keepass",
"UUID": "com.victorgrycuk.keepass.generate",
"PropertyInspectorPath": "PropertyInspector/KeePassGeneratePI.html"
Expand All @@ -36,7 +36,7 @@
"Description": "Simple interface to retrieve information from KeePass database. Unofficial.",
"Icon": "Images/pluginIcon",
"URL": "https://github.com/VictorGrycuk/StreamDeck-KeePass",
"Version": "1.1",
"Version": "1.2",
"CodePath": "streamdeck-keepass",
"Category": "KeePass",
"CategoryIcon": "Images/categoryIcon",
Expand Down

0 comments on commit 256f30b

Please sign in to comment.