Example usage for java.security MessageDigest digest

List of usage examples for java.security MessageDigest digest

Introduction

In this page you can find the example usage for java.security MessageDigest digest.

Prototype

public byte[] digest(byte[] input) 

Source Link

Document

Performs a final update on the digest using the specified array of bytes, then completes the digest computation.

Usage

From source file:it.smartcommunitylab.aac.oauth.AACOAuth2Utils.java

private static String getS256CodeChallenge(String codeVerifier) {
    MessageDigest md;
    try {// ww  w  .  j  av a  2 s.  com
        md = MessageDigest.getInstance("SHA-256");
    } catch (NoSuchAlgorithmException e) {
        throw new IllegalArgumentException("No such algorithm [SHA-256]");
    }
    byte[] sha256 = md.digest(Utf8.encode(codeVerifier));
    String codeChallenge = Base64.encodeBase64URLSafeString(sha256);
    return codeChallenge;
}