public static String crypt(final String text,final String salt){
  try {
    final MessageDigest md=MessageDigest.getInstance(SHA_512);
    md.update(salt.getBytes(StandardCharsets.UTF_8));
    final byte[] digest=md.digest(text.getBytes(StandardCharsets.UTF_8));
    return String.format("%064x",new BigInteger(1,digest));
  }
 catch (  final NoSuchAlgorithmException e) {
    throw new IllegalStateException("The SHA512Crypt class uses an invalid algorithm",e);
  }
}

public static String crypt ( final String text , final String salt ) { try { final MessageDigest md = MessageDigest . getInstance ( SHA_512 ) ; md . update ( salt . getBytes ( StandardCharsets . UTF_8 ) ) ; final byte [ ] digest = md . digest ( text . getBytes ( StandardCharsets . UTF_8 ) ) ; return String . format ( "%064x" , new BigInteger ( 1 , digest ) ) ; } catch ( final NoSuchAlgorithmException e ) { throw new IllegalStateException ( "The SHA512Crypt class uses an invalid algorithm" , e ) ; } }
returns the sha256 - hash of the given string using the specified salt
