Dcrypt\Random::bytes PHP Method

bytes() public static method

Return securely generated random bytes.
public static bytes ( integer $bytes ) : string
$bytes integer Number of bytes to get
return string
    public static function bytes($bytes)
    {
        if (\function_exists('random_bytes')) {
            return \random_bytes($bytes);
        } elseif (\function_exists('mcrypt_create_iv')) {
            return self::fromMcrypt($bytes);
        }
        self::toss();
        // @codeCoverageIgnore
    }

Usage Example

Beispiel #1
0
 public static function githubApiLoginUrl()
 {
     $state = \Session::get('state');
     if ($state === null) {
         $state = md5(\Dcrypt\Random::bytes(16));
         \Session::put('state', $state);
     }
     $url = urlencode('https://' . $_SERVER['HTTP_HOST']);
     $cid = env('APIGENCI_ID');
     return "https://github.com/login/oauth/authorize?client_id={$cid}&redirect_uri={$url}&scope=write:repo_hook&state={$state}";
 }
All Usage Examples Of Dcrypt\Random::bytes