Day 3?? Week 2 – Debugging, Typecasting, and Encryptions

Hi everyone 🙂 Sorry, been busy with school/work, finally found some time to finish up my week 2 problem sets, took me a long time to figure out how to do the crack problem set.

Screen Shot 2017-06-06 at 3.01.38 PM

I understood the concepts, and had it planned in my head, but to put it in codes was incredibly frustrating.

Here’s some tips to think about:
I was mostly having problem with how declare a variable that is 4 letters blank (not spaces). The problem is space is not equals to \0. I couldn’t declare 4 letter string with 1 letter and 3 spaces, or 2 letter 2 spaces.

The solutions is to control \0 points.

For example:

// declaring a variable that takes 5 slots (eventhough you only have 4 letter password, the last space is for \0, instead of using string, use char data type.

char password[5];

// then for control;

password[1] = ‘\0’;

// This way, password[0] is the letter you are testing, then use crypt(password, hash) to compare. Confused? Here’s an example, think of * as space. password A*** is not the same as A\0. Eventhough they both are visually the same.


The second problem I had was comparing my guess and the hash given. For unknown reason, I’m not able to do if (attempt == hash), I had to do loops if (attempt[i] == hash[i]). So C++ had me checking the hash character by character, instead of the whole string. I couldn’t understand why. Please comment if anyone understands or would like to see my partial code for the function?


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s