[Tutorial] How to Make MD5 Hashes!

Discussion in 'Resources' started by Kodfod, Sep 21, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    Kodfod

    Today I'm going to show you how to make MD5 Hashes. There is a built in method of doing this inside Java.

    Here is a demonstration of what it looks like:

    Code:JAVA
    1. //Start Encrypting process
    2. String keyedpass = args[1];
    3. //Stores What the was
    4.  
    5. try {
    6. MessageDigest m = MessageDigest.getInstance("MD5");
    7. //Sets the Encrypting type to MD5
    8. m.reset();
    9. m.update(keyedpass.getBytes());
    10. //Gets a byte array of the string aka Password
    11. byte[] digest = m.digest();
    12. BigInteger bigInt = new BigInteger(1, digest);
    13. //Gets the new byte array of the Encrypted text
    14. String hashtext = bigInt.toString(16);
    15. //Turns the Byte Array into a string.
    16. while (hashtext.length() < 32) {
    17. hashtext = 0+hashtext;
    18. //Makes the MD5 Encryption readable. 0 = padding.
    19. }


    *ended up commenting instead of making more paragraphs*

    If you have any questions feel free to ask!

    Picture of my plugin showing what a simple Password (Hello) Turns into:

    [​IMG]
     
    Aengo, Jozeth, jtjj222 and 1 other person like this.
  2. Offline

    Megolas

    "Hello" ain't a good pass :3 Thanks for the tutorial!
     
  3. Offline

    Kodfod

    LOL No, not it isn't but it was just an example.

    Thanks for reading =)

    Edit: As a side note, the hash IS CASE SENSITVE so Hello will turn out different then hello.
     
  4. Offline

    Jozeth

    I was looking around for encrypting passwords, etc... Thanks.
     
  5. Offline

    confuserr

    I wouldn't recommend using md5 for hashing passwords, it was broken a while ago. Use at least Sha1 instead for passwords.
     
    Acrobot and Jozeth like this.
  6. Do you know how to salt a password?
     
    jtjj222 likes this.
  7. Offline

    Kodfod

    Randomly place random non-related characters. Make sure you know how to undo what you did/Check with the same letter you salted with.

    As for salting a password, for minecraft related things, it's not really needed. Sha-1 isn't needed. MD-5 will fit your needs.
     
    jtjj222 likes this.
  8. Ok, thanks. Also I was doing some research into this the other day and some people recommended MD5'ing the password 1000 times via an iterator. Do you think this is needed?
     
  9. Offline

    Icyene

    Or, the very compact version:

    Code:Java
    1.  
    2. new BigInteger(1, MessageDigest.getInstance("MD5").digest(err.getBytes())).toString();
    3.  

    :D
     
  10. Does that work? Also don't MD5 hashes have letters in them too?
     
  11. Offline

    Icyene

    iKeirNez

    Yes, it will work. Its practically the same as the original answer, only made much more compact.
     
  12. Ok, I may use your one instead then :D
     
  13. Offline

    hawkfalcon

    Whatcha use a md_5 for?
     
  14. I like to use him sometimes and store him in my database, its very dark in there. Occasionally he gets to come out but not for long.
     
  15. Offline

    Comphenix

    You really shouldn't use MD5 for password hashing. It's not just theoretically broken, it's easily brute-forced in practice. Salting can help, but it doesn't solve the fundamental problem - MD5 was not designed for password hashing. As it's primary application is verifying data integrity (checksums), it has a very high throughput (even without a GPU). Unfortunately, that also makes it vulnerable to brute-forcing.

    Instead, use a hash algorithm that's designed for password hashing, such as Bcrypt or PBKDF2. Though ... don't crank the "strenght" too high - otherwise you might have to put the hashing on a separate thread. :p
     
  16. Thanks, will look into that!
     
  17. Offline

    md_5

    //Makes the MD5 Encryption readable. 0 = padding.

    MD5 is a hash not encryption btw.
     
    Aengo, Kodfod and hawkfalcon like this.
Thread Status:
Not open for further replies.

Share This Page