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

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

H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now