Following is a quick example of how to generate an MD5 Hash (SHA-256, SHA-512 or any other supported hash algorithm) of either a String or the byte value of a long. You should be able to adapt for your particular application:
package com.ryanchapin.util;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class HashGenerator {
public static String createHash(long input, String hashAlgorithm) {
// Generate a byte array from the long
// Extract the byte value → Continue reading “Creating a MD5 Hash in Java From Either a String or the Byte Value of a Long”