package com.izouma.nineth.utils;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;

public class TokenUtils {
    public static String genTokenId() {
        try {
            Random random = ThreadLocalRandom.current();
            byte[] r = new byte[32];
            random.nextBytes(r);
            MessageDigest m = MessageDigest.getInstance("MD5");
            m.update(r, 0, r.length);
            return new BigInteger(1, m.digest()).toString(16);
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return null;
    }
}
