Here you can find the source of sha512(String string)
public static byte[] sha512(String string)
//package com.java2s; //License from project: Open Source License import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { /** Hashes the given {@code string} using the SHA-512 algorithm. */ public static byte[] sha512(String string) { return hash("SHA-512", string); }//from w w w .j a v a 2 s . c o m /** Hashes the given {@code string} using the given {@code algorithm}. */ public static byte[] hash(String algorithm, String string) { MessageDigest digest; try { digest = MessageDigest.getInstance(algorithm); } catch (NoSuchAlgorithmException ex) { throw new IllegalArgumentException(String.format("[%s] isn't a valid hash algorithm!", algorithm), ex); } byte[] bytes; try { bytes = string.getBytes("UTF-8"); } catch (UnsupportedEncodingException ex) { throw new IllegalStateException(ex); } return digest.digest(bytes); } }