Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
Pages: (13) </ 1 [2] 3 4 5 6 7 ... >/

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: C question, loops< Next Oldest | Next Newest >
WDef Offline





Group: Members
Posts: 798
Joined: Sep. 2005
Posted: Jan. 12 2008,21:35 QUOTE

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.
Back to top
Profile PM 
^thehatsrule^ Offline





Group: Members
Posts: 3275
Joined: July 2006
Posted: Jan. 12 2008,23:58 QUOTE

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.
Back to top
Profile PM 
WDef Offline





Group: Members
Posts: 798
Joined: Sep. 2005
Posted: Jan. 13 2008,02:07 QUOTE

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.
Back to top
Profile PM 
curaga Offline





Group: Members
Posts: 2163
Joined: Feb. 2007
Posted: Jan. 13 2008,10:58 QUOTE

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.


--------------
There's no such thing as life. Those mean little jocks invented it ;)
-
Windows is not a virus. A virus does something!
Back to top
Profile PM 
curaga Offline





Group: Members
Posts: 2163
Joined: Feb. 2007
Posted: Jan. 13 2008,11:09 QUOTE

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..


--------------
There's no such thing as life. Those mean little jocks invented it ;)
-
Windows is not a virus. A virus does something!
Back to top
Profile PM 
64 replies since Jan. 12 2008,13:35 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

Pages: (13) </ 1 [2] 3 4 5 6 7 ... >/
reply to topic new topic new poll
Quick Reply: C question

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code