Example usage for org.apache.commons.codec.binary Hex getCharsetName

List of usage examples for org.apache.commons.codec.binary Hex getCharsetName

Introduction

In this page you can find the example usage for org.apache.commons.codec.binary Hex getCharsetName.

Prototype

public String getCharsetName() 

Source Link

Document

Gets the charset name.

Usage

From source file:org.onebusaway.gtfs_realtime.alerts_producer_demo.GtfsRealtimeProviderImpl.java

/**
 * Generates a unique fingerprint of the specified value.
 * // w  ww.ja  v  a2 s .  com
 * @param value
 * @return an hex-string of the MD5 fingerprint of the specified value.
 */
private String getHashOfValue(String value) {
    try {
        MessageDigest digest = MessageDigest.getInstance("MD5");
        digest.update(value.getBytes());
        Hex hex = new Hex();
        return new String(hex.encode(digest.digest()), hex.getCharsetName());
    } catch (Exception ex) {
        throw new IllegalStateException(ex);
    }
}