<commit_before>//package com.nfsindustries.luckyrandomgenerator;

import java.util.*;

public class LuckyRandomGenerator {
  public static int smallestAllowedValue = 1;
  public static int biggestAllowedValueInUk = 59;
  public static int biggestAllowedValueInBrazil = 60;

  private String saltchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890@!#$%&*()[];.,<>/{}-+_";

  private int minIntValue = smallestAllowedValue;
  private int maxIntValue;
  private Random random = new Random();

  public LuckyRandomGenerator() {
    maxIntValue = biggestAllowedValueInUk;
  }

  public LuckyRandomGenerator(int min, int max) {
    minIntValue = min;
    maxIntValue = max;
  }

  public LuckyRandomGenerator(int max) {
    maxIntValue = max;
  }

  /**
  * Rolled a fair dice, guaranteed to be random
  */
  public int generateRandomNumber(int min, int max) {
    Random random = new Random();
    return random.nextInt(max - min + 1) + min;
  }

  public Set generateLotteryTickets(int quantity) {
    SortedSet<Integer> tickets = new TreeSet<Integer>();
    while(tickets.size() < quantity) {
      tickets.add(generateRandomNumber());
    }
    return tickets;
  }

  public Set generateLotteryTickets(int quantity, int min, int max) {
    minIntValue = min;
    maxIntValue = max;
    return generateLotteryTickets(quantity);
  }

  public String generateRandomString(int length, String aSaltString) {
    saltchars = aSaltString;
    if (length < 1) {
      throw new IllegalArgumentException("length < 1: " + length);
    }
    StringBuilder salt = new StringBuilder();
    while (salt.length() < length) {
      int index = (int) (random.nextFloat() * saltchars.length());
      salt.append(saltchars.charAt(index));
    }
    final String saltStr = salt.toString();
    return saltStr;
  }

  public String generateRandomString(int length) {
    if (length < 1) {
      throw new IllegalArgumentException("length < 1: " + length);
    }
    StringBuilder salt = new StringBuilder();
    while (salt.length() < length) {
      int index = (int) (random.nextFloat() * saltchars.length());
      salt.append(saltchars.charAt(index));
    }
    String saltStr = salt.toString();
    return saltStr;
  }

  public Set generateLotteryTickets(int quantity, int max) {
    maxIntValue = max;
    return generateLotteryTickets(quantity);
  }

  public void printLotteryTickets(Set<Integer> tickets) {
    for (int currentTicket : tickets) {
      System.out.println("Ticket: " + String.valueOf(currentTicket));
    }
  }

  /**
  * Rolled a fair dice, guaranteed to be random
  */
  public int generateRandomNumber() {
    return generateRandomNumber(minIntValue, maxIntValue);
  }

  public static void main(final String... args) {
    LuckyRandomGenerator generator = new LuckyRandomGenerator();
    int randomNumber = generator.generateRandomNumber();
    String randomNumberString = String.valueOf(randomNumber);
    System.out.println("Random Number: " + randomNumberString);
    generator.printLotteryTickets(generator.generateLotteryTickets(6));
    System.out.println("Random String: " + generator.generateRandomString(10));<commit_msg>Using secure random and optimized performance<commit_after>//package com.nfsindustries.luckyrandomgenerator;

import java.security.SecureRandom;
import java.util.*;

public class LuckyRandomGenerator {
    public static int smallestAllowedValue = 1;
    public static int biggestAllowedValueInUk = 59;
    public static int biggestAllowedValueInBrazil = 60;

    private String saltchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890@!#$%&*()[];.,<>/{}-+_";

    private int minIntValue = smallestAllowedValue;
    private int maxIntValue;
    private SecureRandom random = new SecureRandom();


    public LuckyRandomGenerator() {
        maxIntValue = biggestAllowedValueInUk;
    }

    public LuckyRandomGenerator(final String locale) {
        if (locale.equalsIgnoreCase("uk")) {
            maxIntValue = biggestAllowedValueInUk;
        }
    }

    public LuckyRandomGenerator(int min, int max) {
        minIntValue = min;
        maxIntValue = max;
    }

    public LuckyRandomGenerator(int max) {
        maxIntValue = max;
    }

    /**
     * Rolled a fair dice, guaranteed to be random
     */
    public int generateRandomNumber(int min, int max) {
        return random.nextInt(max - min + 1) + min;
    }

    public Set<Integer> generateLotteryTickets(int quantity) {
        SortedSet<Integer> tickets = new TreeSet<Integer>();
        while(tickets.size() < quantity) {
            tickets.add(generateRandomNumber());
        }
        return tickets;
    }

    public Set generateLotteryTickets(int quantity, int min, int max) {
        minIntValue = min;
        maxIntValue = max;
        return generateLotteryTickets(quantity);
    }

    public String generateRandomString(int length, String aSaltString) {
        saltchars = aSaltString;
        if (length < 1) {
            throw new IllegalArgumentException("length < 1: " + length);
        }
        StringBuilder salt = new StringBuilder();
        while (salt.length() < length) {
            int index = (int) (random.nextFloat() * saltchars.length());
            salt.append(saltchars.charAt(index));
        }
        final String saltStr = salt.toString();
        return saltStr;
    }

    public String generateRandomString(int length) {
        if (length < 1) {
            throw new IllegalArgumentException("length < 1: " + length);
        }
        StringBuilder salt = new StringBuilder();
        while (salt.length() < length) {
            int index = (int) (random.nextFloat() * saltchars.length());
            salt.append(saltchars.charAt(index));
        }
        String saltStr = salt.toString();
        return saltStr;
    }

    public Set generateLotteryTickets(int quantity, int max) {
        maxIntValue = max;
        return generateLotteryTickets(quantity);
    }

    /**
     * Rolled a fair dice, guaranteed to be random
     */
    public int generateRandomNumber() {
        return generateRandomNumber(minIntValue, maxIntValue);
    }

  public void printLotteryTickets(Set<Integer> tickets) {
    for (int currentTicket : tickets) {
      System.out.println("Ticket: " + String.valueOf(currentTicket));
    }
  }

  public static void main(final String... args) {
    LuckyRandomGenerator generator = new LuckyRandomGenerator();
    int randomNumber = generator.generateRandomNumber();
    String randomNumberString = String.valueOf(randomNumber);
    System.out.println("Random Number: " + randomNumberString);
    generator.printLotteryTickets(generator.generateLotteryTickets(6));
    System.out.println("Random String: " + generator.generateRandomString(10));
{'fraction_non_alphanumeric': 0.1047774966512874, 'fraction_numerical': 0.0068462568834648015, 'mean_word_length': 3.2237586423632933, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4446560', 'n_tokens_mistral': 1971, 'n_tokens_neox': 1878, 'n_words': 466}