💻 How to create Salted MD5 String in Java for token based security

in programming •  7 years ago 

Hello Steemian,

This is Ravi Here and in this program, you learn about how to create saltedmd5string for token based security in java or data table.

kkmk.jpg

By this program helps for Beginners programmer .

package beans;

import java.security.NoSuchAlgorithmException;

public class SaltedMD5String {
    
    public String getSecureHasPassword(String haspass) throws NoSuchAlgorithmException
    {
        byte saltedbytes[] = getSalt(haspass);
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < saltedbytes.length; ++i) 
        {
              sb.append(Integer.toHexString((saltedbytes[i] & 0xFF) | 0x100).substring(1,3));
        }
        return sb.toString();
    }
    
    public byte[] getSalt(String haspass) throws NoSuchAlgorithmException
    {
        java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
        byte[] array = md.digest(haspass.getBytes());
        return array;
    }
}

Hope ! Some people like my valuable post...

follow @ravik2492 for more post

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

This post has received gratitude of 0.53 % from @appreciator thanks to: @ravik2492.

You got a 0.51% upvote from @postpromoter courtesy of @ravik2492! Want to promote your posts too? Check out the Steem Bot Tracker website for more info. If you would like to support development of @postpromoter and the bot tracker please vote for @yabapmatt for witness!