<commit_before>/*
 * Copyright 2022-2022 Asynchronous Game Query Library
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.ibasco.agql.core.util;

import org.apache.commons.lang3.RandomUtils;

import java.io.Serializable;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Base64;

public class UUID implements Serializable {

    private transient static SecureRandom sRand;

    private byte[] data;

    private String dataStr;

    private UUID() {
        try {
            sRand = SecureRandom.getInstanceStrong();
        } catch (NoSuchAlgorithmException e) {
            throw new IllegalStateException(e);
        }
    }

    public static UUID create() {
        UUID id = new UUID();
        byte[] rbytes = new byte[8];
        sRand.nextBytes(rbytes);
        id.data = rbytes;
        return id;
    }

    public byte[] getBytes() {
        return data;
    }

    public int getInteger() {
        byte[] intBytes = new byte[4];
        intBytes[0] = data[0];
        intBytes[1] = data[2];
        intBytes[2] = data[4];
        intBytes[3] = data[6];
        return Math.abs(ByteUtil.toIntegerLE(intBytes));
    }

    public int nextInteger() {
        byte[] intBytes = new byte[4];
        for (int i = 0; i < intBytes.length; i++)
            intBytes[i] = data[RandomUtils.nextInt(0, 8)];
        return ByteUtil.toIntegerLE(intBytes);
    }

    @Override
    public String toString() {
        if (dataStr == null) {
            dataStr = Base64.getEncoder().encodeToString(data).toUpperCase().replaceAll("[/=+]", "");
        }
        return dataStr;
    }
}
<commit_msg>Replace SecureRandom with Random as the call to SecureRandom.nextBytes() hangs on linux<commit_after>/*
 * Copyright (c) 2022 Asynchronous Game Query Library
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.ibasco.agql.core.util;

import org.apache.commons.lang3.RandomUtils;

import java.io.Serializable;
import java.util.Base64;
import java.util.Random;

public class UUID implements Serializable {

    private transient static Random sRand;

    private byte[] data;

    private String dataStr;

    private UUID() {
        //sRand = SecureRandom.getInstanceStrong();
        sRand = new Random();
    }

    public static UUID create() {
        UUID id = new UUID();
        byte[] rbytes = new byte[8];
        sRand.nextBytes(rbytes);
        id.data = rbytes;
        return id;
    }

    public byte[] getBytes() {
        return data;
    }

    public int getInteger() {
        byte[] intBytes = new byte[4];
        intBytes[0] = data[0];
        intBytes[1] = data[2];
        intBytes[2] = data[4];
        intBytes[3] = data[6];
        return Math.abs(ByteUtil.toIntegerLE(intBytes));
    }

    public int nextInteger() {
        byte[] intBytes = new byte[4];
        for (int i = 0; i < intBytes.length; i++)
            intBytes[i] = data[RandomUtils.nextInt(0, 8)];
        return ByteUtil.toIntegerLE(intBytes);
    }

    @Override
    public String toString() {
        if (dataStr == null) {
            dataStr = Base64.getEncoder().encodeToString(data).toUpperCase().replaceAll("[/=+]", "");
        }
        return dataStr;
    }
}

{'fraction_non_alphanumeric': 0.10790523105794042, 'fraction_numerical': 0.013605442176870748, 'mean_word_length': 2.6569468267581473, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '132314', 'n_tokens_mistral': 1266, 'n_tokens_neox': 1213, 'n_words': 392}