Thread: Ways to speed up a bruteforce-style program

  1. #16
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Why don't you use any of the is functions? isalnum would give you any letter or digit, or isprint would tell you if it was a printable character. Most of those checks are going to be lookup tables anyway. isprint is going to give you pretty much every valid character that would be used, and should be a fast way to see if the resulting check's suggested encoding character was valid or not. It seems like your if check you use a lot could be replaced with:
    Code:
    //if((ch < 'A') || (ch>90 && ch<97)) {
    if( isprint( ch ) ) // or isalnum .. if you're assuming no punctuation/whitespace to start
    I'm also not sure about your rule where you can't be entering nonpunctuation. I guess because we're assuming that the encrypted text doesn't start a line with a period? Was that a stipulation by the OP?


    Quzah.
    Hope is the first step on the road to disappointment.

  2. #17
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by quzah View Post
    Why don't you use any of the is functions? isalnum would give you any letter or digit, or isprint would tell you if it was a printable character. Most of those checks are going to be lookup tables anyway. isprint is going to give you pretty much every valid character that would be used, and should be a fast way to see if the resulting check's suggested encoding character was valid or not. It seems like your if check you use a lot could be replaced with:
    Code:
    //if((ch < 'A') || (ch>90 && ch<97)) {
    if( isprint( ch ) ) // or isalnum .. if you're assuming no punctuation/whitespace to start
    I'm also not sure about your rule where you can't be entering nonpunctuation. I guess because we're assuming that the encrypted text doesn't start a line with a period? Was that a stipulation by the OP?


    Quzah.
    That's right:
    has been "encrypted" like this, using a five letter lowercase word.
    I didn't want to limit my program to a lowercase password, though.

    All these char's are printable. isprint() doesn't help, since it wouldn't exclude char's like '['. I did allow some such char's as possibles later on, but at first, I thought it would be too slow if I included them as possible char's in the search.

  3. #18
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Adak View Post
    All these char's are printable. isprint() doesn't help, since it wouldn't exclude char's like '['. I did allow some such char's as possibles later on, but at first, I thought it would be too slow if I included them as possible char's in the search.
    [ is a printable character: man isprint


    Quzah.
    Hope is the first step on the road to disappointment.

  4. #19
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by quzah View Post
    [ is a printable character: man isprint


    Quzah.
    Sure, that's why isprint() wouldn't exclude it, and why I didn't use isprint(). Although I later allowed some non-word char's into the search for the password, I never allowed any char with a value above 'z'.

  5. #20
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by Adak View Post
    Sure, that's why isprint() wouldn't exclude it, and why I didn't use isprint(). Although I later allowed some non-word char's into the search for the password, I never allowed any char with a value above 'z'.
    or isalnum .. if you're assuming no punctuation/whitespace to start
    Or even isalpha if you've got something against numbers.

  6. #21
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    That's the duality - on the one hand, I like the idea of a general substitution program, that would handle numbers, punctuation, and space(s).

    On the other hand, that wasn't part of the OP's problem, and I did want to stay more or less, focused on that.

    I'll put together something to test the better algorithm idea from my earlier post (#15). What do you think - should a program like this include numbers and char's like $#@%*=+, or not?

  7. #22
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Adak View Post
    Sure, that's why isprint() wouldn't exclude it, and why I didn't use isprint(). Although I later allowed some non-word char's into the search for the password, I never allowed any char with a value above 'z'.
    I misunderstood why you weren't using it. The point I was going for was that those functions are probably faster, because they're likely optimized and are probably just implimented as macro or a lookup table.

    Quzah.
    Hope is the first step on the road to disappointment.

  8. #23
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Awww! OK. Now I get what you meant. Merry Christmas, Quzah.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Keeping program running at constant speed.
    By twinzen in forum C++ Programming
    Replies: 2
    Last Post: 07-31-2010, 03:15 AM
  2. different ways to program
    By herWter in forum Windows Programming
    Replies: 3
    Last Post: 07-07-2008, 12:41 AM
  3. Creating a Carriage-Return style Break in a program
    By JoeMomma5000 in forum C Programming
    Replies: 2
    Last Post: 10-29-2002, 01:06 AM
  4. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM