Skip to content

Commit

Permalink
Bugfix: Fix password profile 'At least 1 per set *'
Browse files Browse the repository at this point in the history
  • Loading branch information
Rookiestyle committed Feb 22, 2022
1 parent 7bf2f9b commit 161d60a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
//
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:
[assembly: AssemblyVersion("2.14")]
[assembly: AssemblyFileVersion("2.14")]
[assembly: AssemblyVersion("2.14.1")]
[assembly: AssemblyFileVersion("2.14.1")]
[assembly: Guid ("5d5cc62b-d6f6-4e0b-a7ff-3d5ef21dd656")]
13 changes: 12 additions & 1 deletion src/PwProfile1PerSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public override ProtectedString Generate(PwProfile prf, CryptoRandomStream crsRa

string sPattern = MapCharsets2Pattern(prf);
p.Pattern = sPattern;
int iLength = p.Pattern.Length;
int iLength = GetPatternLength(p.Pattern);

//Add additionaly specified characters if any
//Increase overall length of generated password by 1: 1 per set = at least 1 out of the additinaly specified characters
Expand All @@ -45,6 +45,17 @@ public override ProtectedString Generate(PwProfile prf, CryptoRandomStream crsRa
return ProtectedString.Empty;
}

private int GetPatternLength(string sPattern)
{
//Some character classes will be escaped
//Those \ must be ignored when calculating character length
var sHelp = sPattern.Replace("\\\\", string.Empty);
int l = (sPattern.Length - sHelp.Length) / 2;
sHelp = sHelp.Replace("\\", string.Empty);
l += sHelp.Length;
return l;
}

private void FinalizePattern(PwProfile p, string sPattern, string sAdditionalChars, int iLength, out bool bSuccess)
{
bSuccess = false;
Expand Down
2 changes: 1 addition & 1 deletion version.info
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
:
PasswordChangeAssistant:2.14
PasswordChangeAssistant:2.14.1
PasswordChangeAssistant!de:9
PasswordChangeAssistant!it:3
PasswordChangeAssistant!pt:5
Expand Down

0 comments on commit 161d60a

Please sign in to comment.