<?php

declare(strict_types=1);

namespace PhpWA\Crypto;

use InvalidArgumentException;

final class SystemRandomSource implements RandomSourceInterface
{
    public function bytes(int $length): string
    {
        if ($length < 0 || $length > 1048576) {
            throw new InvalidArgumentException('Random byte length is out of range.');
        }
        return random_bytes($length);
    }
}
