예제 #1
0
 /**
  * @param int  $length
  * @param bool $bin2hex
  * @return string
  */
 public function generate($length, $bin2hex = false)
 {
     $hash = Strings::random($length);
     if (!empty($bin2hex)) {
         return bin2hex($hash);
     }
     return $hash;
 }
예제 #2
0
파일: KeyCommand.php 프로젝트: vvval/spiral
 /**
  * @param DirectoriesInterface $directories
  * @param FilesInterface       $files
  * @param EncrypterConfig      $config
  */
 public function perform(DirectoriesInterface $directories, FilesInterface $files, EncrypterConfig $config)
 {
     $envFilename = $directories->directory('root') . '.env';
     if (!$files->exists($envFilename)) {
         $this->writeln("<fg=red>'env.' file does not exists, unable to sek encryption key.</fg=red>");
     }
     $files->write($envFilename, str_replace($config->getKey(), Strings::random(32), $files->read($envFilename)));
     $this->writeln("<info>Encryption key has been successfully updated.</info>");
 }
예제 #3
0
 /**
  * Unique wrapper.
  *
  * @return string
  */
 private static function createWrapper()
 {
     $wrapper = '(~' . Strings::random(64) . '~)';
     if (in_array($wrapper, self::$wrappers)) {
         return self::createWrapper();
     }
     return self::$wrappers[] = $wrapper;
 }