Neos\Flow\Utility\Algorithms::generateRandomBytes PHP Method

generateRandomBytes() public static method

Returns a string of random bytes.
public static generateRandomBytes ( integer $count ) : string
$count integer Number of bytes to generate
return string Random bytes
    public static function generateRandomBytes($count)
    {
        return random_bytes($count);
    }

Usage Example

コード例 #1
0
 /**
  * Returns the encryption key from the persistent cache or Data/Persistent directory. If none exists, a new
  * encryption key will be generated and stored in the cache.
  *
  * @return string The configured encryption key stored in Data/Persistent/EncryptionKey
  */
 protected function getEncryptionKey()
 {
     if ($this->encryptionKey === null) {
         $this->encryptionKey = $this->cache->get('encryptionKey');
     }
     if ($this->encryptionKey === false && file_exists(FLOW_PATH_DATA . 'Persistent/EncryptionKey')) {
         $this->encryptionKey = file_get_contents(FLOW_PATH_DATA . 'Persistent/EncryptionKey');
     }
     if ($this->encryptionKey === false) {
         $this->encryptionKey = bin2hex(Utility\Algorithms::generateRandomBytes(48));
         $this->cache->set('encryptionKey', $this->encryptionKey);
     }
     return $this->encryptionKey;
 }
All Usage Examples Of Neos\Flow\Utility\Algorithms::generateRandomBytes