package com.corewing.app.util;

import java.util.Random;

public class CommonGenerateUtil {

    /**
     * 验证码长度
     */
    private static final int CODE_LENGTH = 6;


    /**
     * 验证码有效期（分钟）
     */
    public static final int CODE_EXPIRE_MINUTES = 5;


    /**
     * 生成随机验证码
     *
     * @return 验证码
     */
    public static String generateCode() {
        Random random = new Random();
        StringBuilder code = new StringBuilder();
        for (int i = 0; i < CODE_LENGTH; i++) {
            code.append(random.nextInt(10));
        }
        return code.toString();
    }
}
