<?php

namespace AuthStack\EncryptedLicense;

function str_random(int $length = 16): string
{
    $string = '';

    while (($len = strlen($string)) < $length)
    {
        $size = $length - $len;
        $bytes = random_bytes($size);
        $string .= substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, $size);
    }

    return $string;
}