Skip to content

Commit 9afd706

Browse files
finished compute_altsum()
1 parent ddfb119 commit 9afd706

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

crack.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ int main(int argc, char** argv) {
2424

2525

2626
string compute_primitive_md5(string input) {
27-
unsigned char digest[16];
28-
char* to_hash = new char(input.length());
29-
strcpy(to_hash, input.c_str());
27+
unsigned char digest[16]; //allocate 16 bytes for result, or "digest"
28+
char* to_hash = new char(input.length()); //allocate space for input
29+
strcpy(to_hash, input.c_str()); //copy input into to_hash
3030

31-
MD5((unsigned char*)(to_hash), strlen(to_hash), (unsigned char*)(digest));
32-
return string((char*)&digest, 16);
31+
MD5((unsigned char*)(to_hash), strlen(to_hash), (unsigned char*)(digest)); //compute the md5
32+
return string((char*)&digest, 16); // convert into a string
3333
}
3434

3535
// compute alternate sum
3636
string compute_altsum(string salt, string passwd) {
37-
return "altsum"; // replace altsum with md5(psswd + salt + psswd); TODO: look into the library Alex sent and get rid of the overhead of this function
37+
return compute_primitive_md5(passwd.append(salt).append(passwd)); // maybe just not make this a function?
3838
}
3939

4040

0 commit comments

Comments
 (0)