diff --git a/README.md b/README.md index e1feaec..f1cfc0b 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/StreamDeck-KeePass/StreamDeck-KeePass/KeePassGenerate.cs b/StreamDeck-KeePass/StreamDeck-KeePass/KeePassGenerate.cs index 5a5d270..825e1c5 100644 --- a/StreamDeck-KeePass/StreamDeck-KeePass/KeePassGenerate.cs +++ b/StreamDeck-KeePass/StreamDeck-KeePass/KeePassGenerate.cs @@ -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 @@ -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; } @@ -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 @@ -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) diff --git a/StreamDeck-KeePass/StreamDeck-KeePass/PropertyInspector/KeePassGeneratePI.html b/StreamDeck-KeePass/StreamDeck-KeePass/PropertyInspector/KeePassGeneratePI.html index dd88668..169b461 100644 --- a/StreamDeck-KeePass/StreamDeck-KeePass/PropertyInspector/KeePassGeneratePI.html +++ b/StreamDeck-KeePass/StreamDeck-KeePass/PropertyInspector/KeePassGeneratePI.html @@ -52,6 +52,14 @@ +
+
Characters to Exclude
+ +
+
+
Custom Pattern
+ +
diff --git a/StreamDeck-KeePass/StreamDeck-KeePass/StreamDeck-KeePass.csproj b/StreamDeck-KeePass/StreamDeck-KeePass/StreamDeck-KeePass.csproj index 93f6e6f..ddb2c7f 100644 --- a/StreamDeck-KeePass/StreamDeck-KeePass/StreamDeck-KeePass.csproj +++ b/StreamDeck-KeePass/StreamDeck-KeePass/StreamDeck-KeePass.csproj @@ -12,6 +12,21 @@ 512 true true + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true AnyCPU @@ -27,7 +42,7 @@ AnyCPU pdbonly true - bin\Release\StreamDeck_KeePass.sdPlugin\ + bin\Release\com.victorgrycuk.keepass.sdPlugin\ TRACE prompt 4 @@ -152,6 +167,18 @@ PreserveNewest + + + False + Microsoft .NET Framework 4.7.2 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + $(ProjectDir)\..\..\Tools\DistributionTool.exe -b -i $(ProjectDir)\$(OutDir) -o $(ProjectDir)\$(OutDir) diff --git a/StreamDeck-KeePass/StreamDeck-KeePass/manifest.json b/StreamDeck-KeePass/StreamDeck-KeePass/manifest.json index 5d85383..5848b20 100644 --- a/StreamDeck-KeePass/StreamDeck-KeePass/manifest.json +++ b/StreamDeck-KeePass/StreamDeck-KeePass/manifest.json @@ -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" @@ -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",