summaryrefslogtreecommitdiff
path: root/WinKeyRecover/keyManager
diff options
context:
space:
mode:
Diffstat (limited to 'WinKeyRecover/keyManager')
-rw-r--r--WinKeyRecover/keyManager/CheckIsValid.cs41
-rw-r--r--WinKeyRecover/keyManager/CountMissingChars.cs27
-rw-r--r--WinKeyRecover/keyManager/GeneratePattern.cs37
-rw-r--r--WinKeyRecover/keyManager/GetMissingPositons.cs26
-rw-r--r--WinKeyRecover/keyManager/ReplaceMissings.cs32
5 files changed, 163 insertions, 0 deletions
diff --git a/WinKeyRecover/keyManager/CheckIsValid.cs b/WinKeyRecover/keyManager/CheckIsValid.cs
new file mode 100644
index 0000000..5b6775b
--- /dev/null
+++ b/WinKeyRecover/keyManager/CheckIsValid.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WinKeyRecover
+{
+ internal class CheckIsValid
+ {
+ private string key;
+
+ public bool CheckKey(char[] validChars, string key)
+ {
+ this.key = key.ToUpper();
+
+ if (this.key != string.Empty
+ && this.key.Length == 29
+ && this.key.Contains('*')
+ )
+ {
+ for (int i = 0; i < key.Length; i++)
+ {
+ if (this.key[i] != '-'
+ && this.key[i] != '*'
+ && !validChars.Contains(this.key[i])
+ )
+ {
+ return false;
+ }
+ }
+ }
+ else
+ {
+ return false;
+ }
+
+ return true;
+ }
+ }
+}
diff --git a/WinKeyRecover/keyManager/CountMissingChars.cs b/WinKeyRecover/keyManager/CountMissingChars.cs
new file mode 100644
index 0000000..b92b357
--- /dev/null
+++ b/WinKeyRecover/keyManager/CountMissingChars.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WinKeyRecover
+{
+ internal class CountMissingChars
+ {
+ private int missing = 0;
+
+ public int Count(string key)
+ {
+ for (int i = 0; i < key.Length; i++)
+ {
+ if (key[i] == '*')
+ {
+ missing++;
+ }
+ }
+
+ return missing;
+ }
+ }
+}
diff --git a/WinKeyRecover/keyManager/GeneratePattern.cs b/WinKeyRecover/keyManager/GeneratePattern.cs
new file mode 100644
index 0000000..dbd0809
--- /dev/null
+++ b/WinKeyRecover/keyManager/GeneratePattern.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WinKeyRecover
+{
+ internal class GeneratePattern
+ {
+ private readonly List<string> generatedPatterns = new List<string>();
+
+ public List<string> Generate(char[] patternChars, int patternLength, string patternBase = "")
+ {
+ if (patternLength == 1)
+ {
+ for (int i = 0; i < patternChars.Length; i++)
+ {
+ generatedPatterns.Add(patternBase + patternChars[i]);
+ }
+ }
+ else
+ {
+ for (int i = 0; i < patternChars.Length; i++)
+ {
+ string patternNew = patternBase + patternChars[i];
+ _ = Generate(patternChars, patternLength - 1, patternNew);
+ }
+ }
+
+ return generatedPatterns;
+ }
+ }
+}
+
+
diff --git a/WinKeyRecover/keyManager/GetMissingPositons.cs b/WinKeyRecover/keyManager/GetMissingPositons.cs
new file mode 100644
index 0000000..14bf8e8
--- /dev/null
+++ b/WinKeyRecover/keyManager/GetMissingPositons.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WinKeyRecover
+{
+ internal class GetMissingPositions
+ {
+ private readonly List<int> missingPosition = new List<int>();
+
+ public List<int> GetPositions(string key)
+ {
+ for (int i = 0; i < key.Length; i++)
+ {
+ if (key[i] == '*')
+ {
+ missingPosition.Add(i);
+ }
+ }
+
+ return missingPosition;
+ }
+ }
+}
diff --git a/WinKeyRecover/keyManager/ReplaceMissings.cs b/WinKeyRecover/keyManager/ReplaceMissings.cs
new file mode 100644
index 0000000..6e5e1ae
--- /dev/null
+++ b/WinKeyRecover/keyManager/ReplaceMissings.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WinKeyRecover
+{
+ internal class ReplaceMissings
+ {
+ private readonly string key;
+ private readonly List<int> missingPosition;
+
+ public ReplaceMissings(string key, List<int> missingPosition)
+ {
+ this.key = key;
+ this.missingPosition = missingPosition;
+ }
+
+ public string Replace(string pattern)
+ {
+ char[] finalKey = new List<char>(key).ToArray();
+
+ for (int i = 0; i < pattern.Length; i++)
+ {
+ finalKey[missingPosition[i]] = pattern[i];
+ }
+
+ return new string(finalKey);
+ }
+ }
+}