<commit_before>package io.github.hapjava.server.impl.crypto;

import java.util.Base64;
import org.bouncycastle.crypto.Digest;
import org.bouncycastle.crypto.digests.SHA512Digest;

public class HAPSetupCodeUtils {
  private static final String ALPHA_NUMERIC_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

  public static String randomAlphaNumeric(int count) {
    StringBuilder builder = new StringBuilder();
    while (count-- != 0) {
      int character = (int) (Math.random() * ALPHA_NUMERIC_STRING.length());
      builder.append(ALPHA_NUMERIC_STRING.charAt(character));
    }
    return builder.toString();
  }

  public static String generateSetupId() {
    String setupId =
        ""
            + ALPHA_NUMERIC_STRING.charAt((int) (Math.random() * ALPHA_NUMERIC_STRING.length()))
            + ALPHA_NUMERIC_STRING.charAt((int) (Math.random() * ALPHA_NUMERIC_STRING.length()))
            + ALPHA_NUMERIC_STRING.charAt((int) (Math.random() * ALPHA_NUMERIC_STRING.length()))
            + ALPHA_NUMERIC_STRING.charAt((int) (Math.random() * ALPHA_NUMERIC_STRING.length()));
    return setupId;
  }

  private static byte[] calculateHash(final String input, final Digest digest) {
    byte[] inputAsBytes = input.getBytes();
    byte[] retValue = new byte[digest.getDigestSize()];
    digest.update(inputAsBytes, 0, inputAsBytes.length);
    digest.doFinal(retValue, 0);
    return retValue;
  }<commit_msg>incorporate review feedback<commit_after>package io.github.hapjava.server.impl.crypto;

import java.util.Base64;
import org.bouncycastle.crypto.Digest;
import org.bouncycastle.crypto.digests.SHA512Digest;

public class HAPSetupCodeUtils {
  private static final String ALPHA_NUMERIC_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

  public static String randomAlphaNumeric(int count) {
    StringBuilder builder = new StringBuilder();
    while (count-- != 0) {
      int character = (int) (Math.random() * ALPHA_NUMERIC_STRING.length());
      builder.append(ALPHA_NUMERIC_STRING.charAt(character));
    }
    return builder.toString();
  }

  public static String generateSetupId() {
    return randomAlphaNumeric(4);
  }

  private static byte[] calculateHash(final String input, final Digest digest) {
    byte[] inputAsBytes = input.getBytes();
    byte[] retValue = new byte[digest.getDigestSize()];
    digest.update(inputAsBytes, 0, inputAsBytes.length);
    digest.doFinal(retValue, 0);
    return retValue;
  }
{'fraction_non_alphanumeric': 0.11489536315141567, 'fraction_numerical': 0.015182601559294214, 'mean_word_length': 4.358241758241758, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3874613', 'n_tokens_mistral': 821, 'n_tokens_neox': 770, 'n_words': 148}