aboutsummaryrefslogtreecommitdiffhomepage
path: root/misc/random_printable_bytes.php
blob: 9e55fe7c96eda51742b9948215dfabec12840d38 (plain)
1
2
3
4
5
6
7
8
9
10
<?php

/**
 * Generates a cryptographically secure random printable string
 * @return string 
 */
function random_printable_bytes(): string {
    // i think 128 bytes should be enough .. i hope so anyway
    return str_replace(['+', '/', '='], ['-', '_', ''], base64_encode(random_bytes(128)));
}