/*
 * 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;
    }
}

@@ -13,13 +13,12 @@
 ght 
-2022-
+(c) 
 2022
@@ -239,16 +239,18 @@
  *%0A *   
+  
 http://w
@@ -740,101 +740,44 @@
 ava.
-security.NoSuchAlgorithmException;%0Aimport java.security.SecureRandom;%0Aimport java.util.Base64
+util.Base64;%0Aimport java.util.Random
 ;%0A%0Ap
@@ -849,22 +849,16 @@
  static 
-Secure
 Random s
@@ -952,26 +952,10 @@
     
-try %7B%0A            
+//
 sRan
@@ -1004,104 +1004,29 @@
     
-%7D catch (NoSuchAlgorithmException e) %7B%0A            throw new IllegalStateException(e);%0A        %7D
+sRand = new Random();
 %0A   

Replace SecureRandom with Random as the call to SecureRandom.nextBytes() hangs on linux