Hi
I have a few password protected ZIP files I created about 10 years ago, unfortunately i forgot password to it. I've found algorithm created by jwoschitz from github that I want to use. With long passwords it can take a long time to find correct password so can you help me change it so it can be resumable?
- class Program
- {
- #region Private variables
-
-
- private static string password = "p123";
- private static string result;
-
- private static bool isMatched = false;
-
-
-
- private static int charactersToTestLength = 0;
- private static long computedKeys = 0;
-
-
-
- private static char[] charactersToTest =
- {
- 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
- 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
- 'u', 'v', 'w', 'x', 'y', 'z','A','B','C','D','E',
- 'F','G','H','I','J','K','L','M','N','O','P','Q','R',
- 'S','T','U','V','W','X','Y','Z','1','2','3','4','5',
- '6','7','8','9','0','!','$','#','@','-'
- };
-
- #endregion
-
- static void Main(string[] args)
- {
- var timeStarted = DateTime.Now;
- Console.WriteLine("Start BruteForce - {0}", timeStarted.ToString());
-
-
- charactersToTestLength = charactersToTest.Length;
-
-
- var estimatedPasswordLength = 0;
-
- while (!isMatched)
- {
-
-
- estimatedPasswordLength++;
- startBruteForce(estimatedPasswordLength);
- }
-
- Console.WriteLine("Password matched. - {0}", DateTime.Now.ToString());
- Console.WriteLine("Time passed: {0}s", DateTime.Now.Subtract(timeStarted).TotalSeconds);
- Console.WriteLine("Resolved password: {0}", result);
- Console.WriteLine("Computed keys: {0}", computedKeys);
-
- Console.ReadLine();
- }
-
- #region Private methods
-
-
-
-
-
- private static void startBruteForce(int keyLength)
- {
- var keyChars = createCharArray(keyLength, charactersToTest[0]);
-
- var indexOfLastChar = keyLength - 1;
- createNewKey(0, keyChars, keyLength, indexOfLastChar);
- }
-
-
-
-
-
-
-
- private static char[] createCharArray(int length, char defaultChar)
- {
- return (from c in new char[length] select defaultChar).ToArray();
- }
-
-
-
-
-
-
-
-
-
- private static void createNewKey(int currentCharPosition, char[] keyChars, int keyLength, int indexOfLastChar)
- {
- var nextCharPosition = currentCharPosition + 1;
-
- for (int i = 0; i < charactersToTestLength; i++)
- {
-
-
- keyChars[currentCharPosition] = charactersToTest[i];
-
-
- if (currentCharPosition < indexOfLastChar)
- {
- createNewKey(nextCharPosition, keyChars, keyLength, indexOfLastChar);
- }
- else
- {
-
- computedKeys++;
-
-
-
- if ((new String(keyChars)) == password)
- {
- if (!isMatched)
- {
- isMatched = true;
- result = new String(keyChars);
- }
- return;
- }
- }
- }
- }
-
- #endregion
- }