/**
 * Copyright (c) 2015, German Neuroinformatics Node (G-Node)
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted under the terms of the BSD License. See
 * LICENSE file in the root of the Project.
 */

package org.g_node.srv;

import java.util.List;
import java.util.Locale;
import java.util.stream.Collectors;
import org.apache.commons.codec.digest.DigestUtils;

/**
 * Class providing various utility methods.
 *
 * @author Michael Sonntag (sonntag@bio.lmu.de)
 */
public final class Utils {
    /**
     * Method converts a List of Strings to Uppercase, joins the individual entries by a blank space
     * and retrieves a hexadecimal String from the resulting input String using the SHA256 hash algorithm.
     * @param valueList List of Strings.
     * @return Hexadecimal String of the SHA256 encoded input Strings.
     */
    public static String getHashSHA256(final List<String> valueList) {

        final String collectListValues = valueList.stream()
                .map(s -> s.toUpperCase(Locale.ENGLISH))
                .collect(Collectors.joining(" "));

        return DigestUtils.sha256Hex(collectListValues);
    }

}

add hash256 utility method