Programming and Scripting :: C question



For doing a whole lot of permutations, something like C is going to be a lot quicker than a high level scripting language like bash.

AFAIK there's no such thing as regexes in C with the standard libraries.  You have to match and extract strings from first principles using string functions, it's a pain in the balls.

I recall there may be a non-standard lib for C  that does regexes though.  C++ does do regexes.

Do you have a reason to avoid looping?  I expect most approaches  would most likely loop to do this.

EDIT:  googling yields this:

http://linux.duke.edu/~mstenn....#SEC185

If you had a lot of perms to do, maybe try the GSL library.

EDIT1:

echo {a..z} needs version 3 of bash.  No wonder I didn't recognize this.

Quote
Do you have a reason to avoid looping?
I'd ask this myself as well. In any case, using higher-level functions would probably use loops at a lower level anyways.  Since you're doing this for a specific purpose that can be easily implemented, it's probably best to keep it lean.

Perl can do it in one line in a shell:

Code Sample
$ perl -e 'for $i( "a" ... "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" ){print $i, "\n"}'


If you want more complicated eg both upper and lower case plus digits etc I can post a solution.

I didn't have a specific reason to avoid loops, I'm just lazy when I noticed I'd have to do 31 for-loops and long if lines.

Thanks WDef, I knew there had to be a simpler way than 40+ lines of C code.
Since I have a comparably low processor, P3 1Ghz, I will probably output that to a file and trim it in some ways. My password consists of 4 lowercase words of english, finnish and quenya. I consider it quite strong, but still want to test how long it would take to break on my comp. Someone knowing me might have this information also, so I will strip at least these: all lines containing 3+ of the same letter (aaa..), all lines containing x, z, or q because they are very rare (and I didn't use them ;)), and some combinations not even remotely words (gaga).

No piping that to a file though, it would take (only!) about 4 * 10^23 exabytes.

One more thing to ask. Since bash wants to read the whole set before going into it's for loop, could perl handle that line-by-line?
So that I wouldn't waste all my ram+swap and then find out the script got killed before even starting.

The bash version:

for line in `theappthatliststhemall`; do
echo $line | openssl rsa -noout -text -passin stdin -in mykey
done


Edit: I would need the finnish letters of ä and ö also. Substituting ö for z in your one-liner did not print them..

Next Page...
original here.