All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.structurizr.api.Md5Digest Maven / Gradle / Ivy

There is a newer version: 3.1.0
Show newest version
package com.structurizr.api;

import javax.xml.bind.DatatypeConverter;
import java.security.MessageDigest;

/**
 * Creates an MD5 digest of content.
 */
final class Md5Digest {

    private static final String ALGORITHM = "MD5";

    String generate(String content) throws Exception {
        if (content == null) {
            content = "";
        }

        MessageDigest digest = MessageDigest.getInstance(ALGORITHM);
        return DatatypeConverter.printHexBinary(digest.digest(content.getBytes("UTF-8"))).toLowerCase();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy