package top.continew.admin.utils;

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

public class InviteCodeGenerator {
    private static final String CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    private static final int CODE_LENGTH = 8; // 邀请码长度

    public static String generateInviteCode() {
        Random random = new SecureRandom();
        StringBuilder code = new StringBuilder();

        for (int i = 0; i < CODE_LENGTH; i++) {
            int index = random.nextInt(CHARACTERS.length());
            code.append(CHARACTERS.charAt(index));
        }
        return code.toString();
    }

    public static void main(String[] args) {
        // 生成5个邀请码示例
        for (int i = 0; i < 5; i++) {
            System.out.println("邀请码 " + (i + 1) + ": " + generateInviteCode());
        }
    }
}
