# Generator of all possible N symbols strings

After searching the net for a solution to generate of all possible combination of N symbols from given strings, I decide to write one in python.

This is an algorithm for Permutation Generation you can run it from the beginning of the permutation or start it in the middle.

The algorithm is flexible and can handle any password length for given an “alphabet”

The variables:

characters = “abc” #  this will define the alphabet to generate the combination
letter = 3 # This will define how many combination of letters you want to have? the algorithm will start from 1 to the number you choose here.

Run Example:

characters = “ab12”
letter = 2;

Output:

a
b
1
2
aa
ba
1a
2a
ab
bb
1b
2b
a1
b1
11
21
a2
b2
12
22
aaa
baa
1aa
2aa
aba
bba
1ba
2ba
a1a
b1a
11a
21a
a2a
b2a
12a
22a
aab
bab
1ab
2ab
abb
bbb
1bb
2bb
a1b
b1b
11b
21b
a2b
b2b
12b
22b
aa1
ba1
1a1
2a1
ab1
bb1
1b1
2b1
a11
b11
111
211
a21
b21
121
221
aa2
ba2
1a2
2a2
ab2
bb2
1b2
2b2
a12
b12
112
212
a22
b22
122
222

Run Example:

characters = “abc123”
letter = 3;

Output:

a
b
1
2
aa
ba
1a
2a
ab
bb
1b
2b
a1
b1
11
21
a2
b2
12
22
aaa
baa
1aa
2aa
aba
bba
1ba
2ba
a1a
b1a
11a
21a
a2a
b2a
12a
22a
aab
bab
1ab
2ab
abb
bbb
1bb
2bb
a1b
b1b
11b
21b
a2b
b2b
12b
22b
aa1
ba1
1a1
2a1
ab1
bb1
1b1
2b1
a11
b11
111
211
a21
b21
121
221
aa2
ba2
1a2
2a2
ab2
bb2
1b2
2b2
a12
b12
112
212
a22
b22
122
222

# Benchmark Between to Methods that Resize Array in C#

Prob: There is two methods to change size of array in C#. Using a template of a Benchmark program from this informative site, I checked the two ways:

Array.Resize  VS  Array.CopyTo VS Loop

Conclusion: sometime build it your self is not that better then using the build-in commands…

Array.Resize took 30253 ms
Arryay.CopyTo took 29649 ms
Loop took 58323 ms

Solution:

Here is the code that I use

class Program
{
public static void AddCell1(ref double[] vector,int num)
{
int size = vector.Length;
Array.Resize(ref vector,size+1);
vector[size] = num;
}
//————————————————-

public static void AddCell2(ref double[] vector,int num)
{
double[] tempVec = new double[vector.Length+1];
vector.CopyTo(tempVec,0);
tempVec[vector.Length] = num;
vector = tempVec;
}
//————————————————-

public static void AddCell3(ref double[] vector,int num)
{
double[] tempVec = new double[vector.Length+1];
for (int i = 0; i < vector.Length ; i++) {
tempVec[i] = vector[i];
}
tempVec[vector.Length] = num;
vector = tempVec;
}
//————————————————-

public static void Main(string[] args)
{
Console.WriteLine(“Hello World!”);

double[] arr1 = new double[]{};
double[] arr2 = new double[]{};
double[] arr3 = new double[]{};

Stopwatch s1 = Stopwatch.StartNew();
for (int i = 0; i < 100000; i++)
s1.Stop();

Stopwatch s2 = Stopwatch.StartNew();
for (int i = 0; i < 100000; i++)
s2.Stop();

Stopwatch s3 = Stopwatch.StartNew();
for (int i = 0; i < 100000; i++)
s3.Stop();

// TODO: Implement Functionality Here
Console.WriteLine(“{0},{1},{2}”,
s1.ElapsedMilliseconds,
s2.ElapsedMilliseconds,
s3.ElapsedMilliseconds);
Console.Write(“Press any key to continue . . . “);
}
}

# How to temporary erase file in Windows 7 with NTFS without pressing delete button

Weird thing in Windows 7 with NTFS, here is what I accidentally found: If you rename file and add in its end a dot, the file is temporary vanish!!

here is how it happened:

First go to file that you want to delete, in my case the file name is: “win7.ld”
Second: press F2 to rename the file Windows will ask if you sure, and of-course you say YES! Then Windows will not trust you and ask again, and again you will say YES! ## Result

The file as been vanish!!

But, if you want to go back, just press F5 (refresh) the the file will appear again…

Not to worry, using simple search in Google I found a script in this site, and I adapt it for my needs, I post it  here because it could be helpful to other.

To succesful run the script you will required to install AutoITscript, that is AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript and SendKeys). AutoIt is also very small, self-contained and will run on all versions of Windows out-of-the-box with no annoying “runtimes” required!

The script will use all the character or words that in the variable \$Array, to run on all the possibilities and combination of any order, from 2 combination to 7 combination and try to open the container. The script will run until it will find a match or it will exhaust any of your given possibilities.

Note:

• \$truecryptPath is the path of your TrueCrypt program
• \$containerPath is the path to the container that you wont to open
• If the script find the right password it automatically mount the container to one of the free drive letters and open explorer to it.
• The path to the TrueCrypt program and to your container MUST be in DOS-8 characters format, to get it you need to use “dir /x” and CMD.
• you also can save time by eliminate character that you absolutely sure that you didn’t use in your password oryou can change every place in the array to possible combination of your passwordfor example: if I have same patterns for my password and I am using only combination of it
• date of my child = 1308200
• ID number = 123456789
• name of the neighbor = moshe
• family name = ofnick

AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript and SendKeys). AutoIt is also very small, self-contained and will run on all versions of Windows out-of-the-box with no annoying “runtimes” required!

So here is the script:

```dim \$one, \$two, \$three, \$four, \$five, \$six, \$seven, \$eight, \$pw, \$pp, \$count, \$truecryptPath, \$containerPath
\$truecryptPath = "C:PROGRA~1TrueCryptTrueCrypt.exe /q background /s "
\$containerPath = "d:cscs2.tre"
dim \$numberOfCharacters = 92
dim \$Array[\$numberOfCharacters+1]
\$Array="a"
\$Array="b"
\$Array="c"
\$Array="d"
\$Array="e"
\$Array="f"
\$Array="g"
\$Array="h"
\$Array="i"
\$Array="j"
\$Array="k"
\$Array="l"
\$Array="m"
\$Array="n"
\$Array="o"
\$Array="p"
\$Array="q"
\$Array="r"
\$Array="s"
\$Array="t"
\$Array="u"
\$Array="v"
\$Array="w"
\$Array="x"
\$Array="y"
\$Array="z"
\$Array="A"
\$Array="B"
\$Array="C"
\$Array="D"
\$Array="E"
\$Array="F"
\$Array="G"
\$Array="H"
\$Array="I"
\$Array="J"
\$Array="K"
\$Array="L"
\$Array="M"
\$Array="N"
\$Array="O"
\$Array="P"
\$Array="Q"
\$Array="R"
\$Array="S"
\$Array="T"
\$Array="U"
\$Array="V"
\$Array="W"
\$Array="X"
\$Array="Y"
\$Array="Z"
\$Array="!"
\$Array="@"
\$Array="#"
\$Array="\$"
\$Array="%"
\$Array="^"
\$Array="&"
\$Array="*"
\$Array="("
\$Array=")"
\$Array="_"
\$Array="+"
\$Array="~"
\$Array="`"
\$Array="1"
\$Array="2"
\$Array="3"
\$Array="4"
\$Array="5"
\$Array="6"
\$Array="7"
\$Array="8"
\$Array="9"
\$Array="0"
\$Array="-"
\$Array="="
\$Array="["
\$Array="]"
\$Array=""
\$Array="{"
\$Array="}"
\$Array="|"
\$Array=";"
\$Array=":"
\$Array="'"
\$Array=""""
\$Array=","
\$Array="."
\$Array="/"
\$Array="?"
\$count = 0
for \$two = 0 to \$numberOfCharacters
for \$one = 0 to \$numberOfCharacters
\$pw = \$Array[\$one]
\$pw &= \$Array[\$two]
\$count = \$count+1
\$pp  = Run(@COMSPEC & " /c " & \$truecryptPath & " /p "& \$pw & " /e /m ro /m rm /v " &\$containerPath )
ProcessSetPriority(\$pp, 0)
if \$count>25 then
While ProcessExists(\$pp)>0
Wend
EndIf
Next
Next
While ProcessExists(\$pp)>0
Wend
\$count = 0
for \$three = 0 to \$numberOfCharacters
for \$two = 0 to \$numberOfCharacters
for \$one = 0 to \$numberOfCharacters
\$pw = \$Array[\$one]
\$pw &= \$Array[\$two]
\$pw &= \$Array[\$three]
\$count = \$count+1
\$pp  = Run(@COMSPEC & " /c " & \$truecryptPath & " /p "& \$pw & " /e /m ro /m rm /v " &\$containerPath )
ProcessSetPriority(\$pp, 0)
if \$count>25 then
While ProcessExists(\$pp)>0
\$count = 0
Wend
EndIf
Next
Next
Next
While ProcessExists(\$pp)>0
Wend
\$count = 0
for \$four = 0 to \$numberOfCharacters
for \$three = 0 to \$numberOfCharacters
for \$two = 0 to \$numberOfCharacters
for \$one = 0 to \$numberOfCharacters
\$pw = \$Array[\$one]
\$pw &= \$Array[\$two]
\$pw &= \$Array[\$three]
\$pw &= \$Array[\$four]
\$count = \$count+1
\$pp  = Run(@COMSPEC & " /c " & \$truecryptPath & " /p "& \$pw & " /e /m ro /m rm /v " &\$containerPath )
ProcessSetPriority(\$pp, 0)
if \$count>25 then
While ProcessExists(\$pp)>0
\$count = 0
Wend
EndIf
Next
Next
Next
Next
While ProcessExists(\$pp)>0
Wend
\$count = 0
for \$five = 0 to \$numberOfCharacters
for \$four = 0 to \$numberOfCharacters
for \$three = 0 to \$numberOfCharacters
for \$two = 0 to \$numberOfCharacters
for \$one = 0 to \$numberOfCharacters
\$pw = \$Array[\$one]
\$pw &= \$Array[\$two]
\$pw &= \$Array[\$three]
\$pw &= \$Array[\$four]
\$pw &= \$Array[\$five]
\$count = \$count+1
\$pp  = Run(@COMSPEC & " /c " & \$truecryptPath & " /p "& \$pw & " /e /m ro /m rm /v " &\$containerPath )
ProcessSetPriority(\$pp, 0)
if \$count>25 then
While ProcessExists(\$pp)>0
Wend
\$count = 0
EndIf
Next
Next
Next
Next
Next
While ProcessExists(\$pp)>0
Wend
\$count = 0
FOR \$six = 0 to \$numberOfCharacters
for \$five = 0 to \$numberOfCharacters
for \$four = 0 to \$numberOfCharacters
for \$three = 0 to \$numberOfCharacters
for \$two = 0 to \$numberOfCharacters
for \$one = 0 to \$numberOfCharacters
\$pw = \$Array[\$one]
\$pw &= \$Array[\$two]
\$pw &= \$Array[\$three]
\$pw &= \$Array[\$four]
\$pw &= \$Array[\$five]
\$pw &= \$Array[\$six]
\$count = \$count+1
\$pp  = Run(@COMSPEC & " /c " & \$truecryptPath & " /p "& \$pw & " /e /m ro /m rm /v " &\$containerPath )
ProcessSetPriority(\$pp, 0)
if \$count>25 then
While ProcessExists(\$pp)>0
Wend
\$count = 0
EndIf
Next
Next
Next
Next
Next
Next
While ProcessExists(\$pp)>0
Wend
\$count = 0
for \$seven = 0 to \$numberOfCharacters
FOR \$six = 0 to \$numberOfCharacters
for \$five = 0 to \$numberOfCharacters
for \$four = 0 to \$numberOfCharacters
for \$three = 0 to \$numberOfCharacters
for \$two = 0 to \$numberOfCharacters
for \$one = 0 to \$numberOfCharacters
\$pw = \$Array[\$one]
\$pw &= \$Array[\$two]
\$pw &= \$Array[\$three]
\$pw &= \$Array[\$four]
\$pw &= \$Array[\$five]
\$pw &= \$Array[\$six]
\$pw &= \$Array[\$seven]
\$count = \$count+1
\$pp  = Run(@COMSPEC & " /c " & \$truecryptPath & " /p "& \$pw & " /e /m ro /m rm /v " &\$containerPath )
ProcessSetPriority(\$pp, 0)
if \$count>25 then
While ProcessExists(\$pp)>0
Wend
\$count = 0
EndIf
Next
Next
Next
Next
Next
Next
Next
While ProcessExists(\$pp)>0
Wend
for \$eight = 0 to \$numberOfCharacters
for \$seven = 0 to \$numberOfCharacters
FOR \$six = 0 to \$numberOfCharacters
for \$five = 0 to \$numberOfCharacters
for \$four = 0 to \$numberOfCharacters
for \$three = 0 to \$numberOfCharacters
for \$two = 0 to \$numberOfCharacters
for \$one = 0 to \$numberOfCharacters
\$pw = \$Array[\$one]
\$pw &= \$Array[\$two]
\$pw &= \$Array[\$three]
\$pw &= \$Array[\$four]
\$pw &= \$Array[\$five]
\$pw &= \$Array[\$six]
\$pw &= \$Array[\$seven]
\$pw &= \$Array[\$eight]
\$count = \$count+1
\$pp  = Run(@COMSPEC & " /c " & \$truecryptPath & " /p "& \$pw & " /e /m ro /m rm /v " &\$containerPath )
ProcessSetPriority(\$pp, 0)
if \$count>25 then
While ProcessExists(\$pp)>0
Wend
\$count = 0
EndIf
Next
Next
Next
Next
Next
Next
Next
Next```