package com.yifu.cloud.plus.v1.yifu.common.core.util;

import lombok.extern.slf4j.Slf4j;

import java.security.SecureRandom;
import java.util.Random;

/**
 * @description: 随机数工具
 * @author: hgw
 * @create: 2022-12-12 17:51:35
 **/
@Slf4j
public class RandomUtil {

	private RandomUtil() {
		throw new IllegalStateException("Utility class");
	}

	/**
	 * 获取六位随机数
	 *
	 * @return
	 * @Author pwang
	 * @Date 2020-08-24 17:26
	 **/
	public static String getSix() {
		log.info("获取随机数开始>>>>>>>>>");
		Random rad = new SecureRandom();
		log.info("获取随机数结束<<<<<<<<<");
		String result = rad.nextInt(1000000) + "";
		if (result.length() != 6) {
			return getSix();
		}
		return result;
	}
}
