• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help implementing MD5 hash correctly into my code.  RSS feed

 
Greenhorn
Posts: 11
Mac Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need help implementing this MD5 hash into my current code to get my authentication program to function properly. Any suggestions? Here are my instructions:::

Option 1: Authentication System
For security-minded professionals, it is important that only the appropriate people gain access to data in a computer system. This is called authentication. Once users gain entry, it is also important that they only see data related to their role in a computer system. This is called authorization. For the zoo, you will develop an authentication system that manages both authentication and authorization. You have been given a credentials file that contains credential information for authorized users. You have also been given three files, one for each role: zookeeper, veterinarian, and admin. Each role file describes the data the particular role should be authorized to access. Create an authentication system that does all of the following:
 Asks the user for a username
 Asks the user for a password
 Converts the password using a message digest five (MD5) hash
o It is not required that you write the MD5 from scratch. Use the code located in this document and follow the comments in it to perform this operation.
 Checks the credentials against the valid credentials provided in the credentials file
o Use the hashed passwords in the second column; the third column contains the actual passwords for testing and the fourth row contains the
role of each user.
 Limits failed attempts to three before notifying the user and exiting the program
 Gives authenticated users access to the correct role file after successful authentication
o The system information stored in the role file should be displayed. For example, if a zookeeper’s credentials is successfully authenticated, then the contents from the zookeeper file will be displayed. If an admin’s credentials is successfully authenticated, then the contents from the admin file will be displayed.
 Allows a user to log out
 Stays on the credential screen until either a successful attempt has been made, three unsuccessful attempts have been made, or a user chooses to exit
You are allowed to add extra roles if you would like to see another type of user added to the system, but you may not remove any of the existing roles.

The following is my code:::



Credentials file:::
griffin.keyes 108de81c31bf9c622f76876b74e9285f "alphabet soup" zookeeper
rosario.dawson 3e34baa4ee2ff767af8c120a496742b5 "animal doctor" admin
bernie.gorilla a584efafa8f9ea7fe5cf18442f32b07b "secret password" veterinarian
donald.monkey 17b1b7d8a706696ed220bc414f729ad3 "M0nk3y business" zookeeper
jerome.grizzlybear 3adea92111e6307f8f2aae4721e77900 "grizzly1234" veterinarian
bruce.grizzlybear 0d107d09f5bbe40cade3de5c71e9e9b7 "letmein" admin

zookeeper:::
Hello, Zookeeper!

As zookeeper, you have access to all of the animals' information and their daily monitoring logs. This allows you to track their feeding habits, habitat conditions, and general welfare.

veterinarian:::
Hello, Veterinarian!

As veterinarian, you have access to all of the animals' health records. This allows you to view each animal's medical history and current treatments/illnesses (if any), and to maintain a vaccination log.

admin:::
Hello, System Admin!

As administrator, you have access to the zoo's main computer system.  This allows you to monitor users in the system and their roles.

 
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suggest you try to understand exactly what that code does, then use it as the basis for a method that your own class will call with appropriate parameters so that you can tell whether or not a passphrase entered by the user has an MD5 hash that is the same as the one you have in your credentials file.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, before you start banging out code at your computer, come up with a plan and try to describe it in plain English. If you can't describe it logically and systematically in plain English, you'll have little to no chance of writing correct code that does what you need it to do.
 
Saloon Keeper
Posts: 3329
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see a lot of cookie-cutter redundancy in your code and not much object oriented code. As a for-instance, it seem like you need a Role class that encapsulates the three roles you've implemented procedurally. The greeting text should be part of the Role object. The role name (e.g. "admin") should be a part of the class. Boolean methods like: hasXXXPermission().
 
Dante King
Greenhorn
Posts: 11
Mac Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have written out my pseudocode and broke it down as much as I possibly could to get the code I have however I tried understanding the MD5 and the code is literally messing me up I have tried to use the MD5 hash as my important piece of code but I can't seem to get it to correctly compare the passwords. So when I failed several times to get it to work properly and tried looking at several youtube videos I wrote the code I posted. it seems to work fine however the issue I have is with the password area. In which I have to use the MD5 hash. I even had a very hard time understanding what in the world was going on in the youtube videos because of the accents and all the darn shortcuts they use in there videos. Thank you I will continue to try to figure out how to implement the MD5 hash.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you share how you broke it down. Sometimes what you think is logical and systematic actually isn't. Or you could be missing important details.
 
Dante King
Greenhorn
Posts: 11
Mac Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys I was finally able to fully understand my MD5 hash code and was able to complete my assignment. Could you all let me know if I did it correctly. To me it looks fine and runs how it should but it would be nice o get feedback on something I can improve on. Thanks once more! Great community!!!

Heres my Authentication code:::
 
Carey Brown
Saloon Keeper
Posts: 3329
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dante King wrote:Hey guys I was finally able to fully understand my MD5 hash code and was able to complete my assignment. Could you all let me know if I did it correctly. To me it looks fine and runs how it should but it would be nice o get feedback on something I can improve on. Thanks once more! Great community!!!

Heres my Authentication code:::

Your Credentials() method creates and fills 'sb' but nowhere do you provide a way to access this. Probably want this to return a String and then return sb.toString().

Edit: Your use of "Credentials" as a method makes it easy to misconstrue as a constructor, which it is not. I suggest changing the name to something else and starting it with a lower case letter.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!