Example usage for org.apache.commons.codec.digest DigestUtils sha512

List of usage examples for org.apache.commons.codec.digest DigestUtils sha512

Introduction

In this page you can find the example usage for org.apache.commons.codec.digest DigestUtils sha512.

Prototype

public static byte[] sha512(String data) 

Source Link

Usage

From source file:pl.bcichecki.rms.client.android.utils.SecurityUtils.java

public static String hashSHA512Base64(String stringToHash) {
    try {/* w  w w.  jav a2s .  co m*/
        byte[] bytes = stringToHash.getBytes(CHARSET_UTF8);
        byte[] md5bytes = DigestUtils.sha512(bytes);
        byte[] base64bytes = Base64.encodeBase64(md5bytes);
        return new String(base64bytes, CHARSET_UTF8);
    } catch (UnsupportedEncodingException e) {
        Log.e(TAG, "This system does not support required hashing algorithms.", e);
        throw new IllegalStateException("This system does not support required hashing algorithms.", e);
    }
}