package com.qmth.themis.business.util;

import com.qmth.themis.common.util.MD5Util;

import java.security.NoSuchAlgorithmException;
import java.util.Objects;
import java.util.StringJoiner;

/**
 * @Description: sessionId util
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2020/6/28
 */
public class SessionUtil {

    /**
     * 生成sessionId
     *
     * @param o
     * @return
     */
    public static String digest(Object... o) throws NoSuchAlgorithmException {
        StringJoiner stringJoiner = new StringJoiner("");
        if (Objects.nonNull(o) && o.length > 0) {
            for (int i = 0; i < o.length; i++) {
                stringJoiner.add(String.valueOf(o[i])).add("-");
            }
        }
        return MD5Util.encoder(stringJoiner.toString().substring(0, stringJoiner.length() - 1));
    }
}
