How to do SHA-512 hashing

0
to call a rest service from a third party, I have to process some SHA-512 hashing.  In Community Commons, there's  a hashing generation called generateHMAC_SHA256_hash.  SHA-512 seems not be available in Mendix. I would like to have some suggestions how to do the SHA-512 hashing ... 
asked
2 answers
1

As Fabian mentioned, you can edit the code in community commons in order to complete your goal. A quick Google search will give you the Java sample below. You can use this piece of code to create your java action.

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public String get_SHA_512_SecurePassword(String passwordToHash, String   salt){
String generatedPassword = null;
    try {
         MessageDigest md = MessageDigest.getInstance("SHA-512");
         md.update(salt.getBytes("UTF-8"));
         byte[] bytes = md.digest(passwordToHash.getBytes("UTF-8"));
         StringBuilder sb = new StringBuilder();
         for(int i=0; i< bytes.length ;i++){
            sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1));
         }
         generatedPassword = sb.toString();
        } 
       catch (NoSuchAlgorithmException e){
        e.printStackTrace();
       }
    return generatedPassword;
}

Source: https://stackoverflow.com/questions/33085493/hash-a-password-with-sha-512-in-java

answered
0

hey thanks !

answered