![]() |
|
[Python] Md5 Cracker Help - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Python] Md5 Cracker Help (/showthread.php?tid=5635452) |
Md5 Cracker Help - XxClassifiedxX - May 30, 2017 I'm still very new to python and I saw a video on making a md5 cracker in python so I tried to make my own. The video's however was in 2.7 while I am using version 3. I'm almost done with it but I keep getting this error. " TypeError: Unicode-objects must be encoded before hashing". Any help is appreciated on how to fix this, the code is below. Thanks. PHP Code * - SIM-1939868 - May 30, 2017 You're looping over pw_list, which is a string, not over the encoded lines in the file. Change it to 'for password in file' * - XxClassifiedxX - May 30, 2017 How did i not see that. thank you Additionally, my if statement is not working for some reason, any ideas why. * - hunter24957 - May 30, 2017 Needs to be encoded as UTF-8 Code: PHP Code Output: Code Please enter your hash: 49f68a5c8493ec2c0bf489821c21fc3b* - XxClassifiedxX - May 30, 2017 thank you so much dude!!! * - SIM-1939868 - May 31, 2017 (May 30, 2017 03:28 PM)hunter24957 Wrote: Needs to be encoded as UTF-8 He did encode it as utf-8 * - hunter24957 - May 31, 2017 (May 31, 2017 11:17 AM)Thommen Wrote: He did encode it as utf-8 No, he simply explicitly told the system the encoding of the file he was reading into memory. As shown below, this prevents most encoding errors when reading a file: PHP Code This (below) converts the string into a byte string which can then be hashed, utf-8 is just a standard type of encoding. PHP Code Works like a charm! 👍 P.S. he literally displayed that the error was due to an encoding issue... (May 30, 2017 01:41 PM)XxClassifiedxX Wrote: "TypeError: Unicode-objects must be encoded before hashing" * - SIM-1939868 - May 31, 2017 (May 31, 2017 02:47 PM)hunter24957 Wrote: P.S. he literally displayed that the error was due to an encoding issue...Look at his code. He opened the file in binary mode, which is fine. He accidently looped over a string instead of the file itself. * - hunter24957 - May 31, 2017 (May 31, 2017 03:36 PM)Thommen Wrote: Look at his code. Yes, I could see that that was also an issue, hence the reason I rewrote his code to ensure it was working due to a few other simple mistakes he made. What I'm trying to get at is that the attempt to iterate over a string was not the only issue. Although I'm glad you pointed it out; as I said before hashlib expects an encoded byte string to hash. However, he did not read the file in binary mode: PHP Code As I said before the "encoding='utf-8'" just explicitly defines the encoding in which to read the file. I'm enjoying this debate but just run my code, it works fine. ✌ * - SIM-1939868 - May 31, 2017 (May 31, 2017 03:51 PM)hunter24957 Wrote: Yes, I could see that that was also an issue, hence the reason I rewrote his code to ensure it was working due to a few other simple mistakes he made.Sure he didnt open it in binary mode but opened it with UTF-8 encoding. Its just that his code worked fine as well, only he made a mistake on the iteration. The error is not about the encoding, its about the mistake that he made in his for loop. * - Goodies - May 31, 2017 Why on earth would you be using Python for this? Good luck finding someone who's a bigger Python advocate than I am. I like hammers, too. It's a good tool, but you wouldn't use a hammer to put in a bolt. Use the right tool for the right job. Python's performance is horrible as a CPU-bound language. Use something lower level. |