package com.eactive.eai.rms.onl.apim.approval;

import java.security.SecureRandom;

public class RandomStringGenerator {
    private static final String CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
    private static final SecureRandom SECURE_RANDOM = new SecureRandom();

    public static String generateString(int length) {
        StringBuilder result = new StringBuilder(length);
        int charactersLength = CHARACTERS.length();

        for (int i = 0; i < length; i++) {
            int randomIndex = SECURE_RANDOM.nextInt(charactersLength);
            result.append(CHARACTERS.charAt(randomIndex));
        }

        return result.toString();
    }
}
