I need logic or some package with functionality to generate random string with specific encoding without using base function random_bytes etc.
Something like this:
$randomLine = random_string($length = 10, $encoding = 'UTF-16');
I need logic or some package with functionality to generate random string with specific encoding without using base function random_bytes etc.
Something like this:
$randomLine = random_string($length = 10, $encoding = 'UTF-16');
If you have php 7.2+, you can use mb_chr
, like this
<?
$max = 10;
$out = '';
$encoding = 'UTF-16';
for ($i = 0;$i<$max;$i++) {
if ($s = mb_chr(rand(1,1114112), $encoding)) {
$out .= $s;
}
}
echo $out;
See http://sandbox.onlinephpfunctions.com/code/a4d39412005473231317758ca5d2fc8d4ad0b27b