package com.winsun.utils;

import java.security.SecureRandom;

/**
 * 随机数工具类
 */
public class RandomUtil {

    /**
     * 获取更安全的随机数
     * @return
     */
    public static double getSecrityRandom() {
        SecureRandom random = null;
        try {
            random = SecureRandom.getInstance("SHA1PRNG");
            return random.nextDouble();
        }catch (Exception e) {
        }
        return 0.0;
    }

    /**
     * 获取int随机数
     * @return
     */
    public static int getSecrityRandomInt(Integer i) {
        SecureRandom random = null;
        try {
            random = SecureRandom.getInstance("SHA1PRNG");
            return random.nextInt(i);
        }catch (Exception e) {
        }
        return 0;
    }
}
