TOTP/TOTPKeyGenerator.php
public static function generate($length = null)
    {
        if ($length === null) {
            $length = self::DEFAULT_LENGTH;
        }
        $characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
        $randomString = '';
        for ($i = 0; $i < $length; ++$i) {
            $randomString .= $characters[rand(0, strlen($characters) - 1)];
        }

        return $randomString;
    }
public static function generate($length = null)
    {
        if ($length === null) {
            $length = self::DEFAULT_LENGTH;
        }
        $characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
        $randomString = '';
        for ($i = 0; $i < $length; ++$i) {
            $randomString .= $characters[rand(0, strlen($characters) - 1)];
        }

        return $randomString;
    }
Generates a TOTP key.

@param int|null $length Key length (default 16)

@return string TOTP key