Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Creating MD5 values using Java

public class HelloWorld{
    public static String MD5(String md5) {
       try {
            java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
            byte[] array = md.digest(md5.getBytes());
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < array.length; ++i) {
              sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1,3));
           }
            return sb.toString();
        } catch (java.security.NoSuchAlgorithmException e) {
        }
        return null;
    }
    
    public static void main(String []args){
         
        String nonce       = String.valueOf(1);
        String timestamp   = String.valueOf(System.currentTimeMillis()/1000);
        String api_key     = "user";
        String api_secret  = "pass";
        String hash        = MD5(String.format("%s:%s:%s:%s", nonce, api_key, api_secret, timestamp));
        String digest      = String.format("%s:%s:%s:%s", nonce, api_key, timestamp, hash);
  
        System.out.println( digest );
     }
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.