src/Generator/CapicomGenerator.php
public function generate($byteCount)
    {
        $bytes = '';

        if (self::isSupported()) {
            try {
                $util = new \COM('CAPICOM.Utilities.1');
                $capicomBytes = base64_decode($util->GetRandom($byteCount, 0));
                if ($capicomBytes) {
                    $bytes = $capicomBytes;
                }
            } catch (\Exception $e) {
            }
        }

        return str_pad($bytes, $byteCount, chr(0));
    }
public function generate($byteCount)
    {
        $bytes = '';

        if (self::isSupported()) {
            try {
                $util = new \COM('CAPICOM.Utilities.1');
                $capicomBytes = base64_decode($util->GetRandom($byteCount, 0));
                if ($capicomBytes) {
                    $bytes = $capicomBytes;
                }
            } catch (\Exception $e) {
            }
        }

        return str_pad($bytes, $byteCount, chr(0));
    }
Generate a string of random data.

@param  integer $byteCount The desired number of bytes.
@return string  Returns the generated string.