Boost regex troubles

closed account (4ET0pfjN)
Hi, this is the brute-force decrypt function I wrote, but it's not really working properly. I just need to find sub-expressions and then the key i is returned, so professor said to find most commonly used English words so I decided to use top 30 (from wikipedia). Is my use of the regular expression correct?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
int bruteForceDecrypt(const char *ciphertext, char *message, const int messageLength) {

   boost::regex re(" the | be | to | of | and | a | in | that | have | I | it | for | not | on | with | he | as | you | do | at | this | but | his | by | from | they | we | say | her | she ");

	for ( int i = 0; i < 65536; i++ )//to go through all the possible keys
	{

		crypt(i,ciphertext,message,messageLength);//decrypt the cipher text first
		
		if (boost::regex_search(message  ,re) == true)
			return i;//return the key if you found a subexpression
	}

  return -1;
}
closed account (o1vk4iN6)
Not sure how spaces are handled in regex, but i'd remove them just to be safe.
closed account (4ET0pfjN)
Hi, I actually started off w/o spaces...
Topic archived. No new replies allowed.