public function fire()
 {
     $defaultKey = di('config')->get('app.key');
     $key = Str::random(32);
     $path = base_path('.env');
     if (file_exists($path)) {
         file_put_contents($path, str_replace($defaultKey, $key, file_get_contents($path)));
         // set the new application key to config service.
         di('config')->set('app.key', $key);
     }
     $this->callOptimize();
     $this->showInfo($key);
 }
Example #2
0
 /**
  * Determine if the MAC for the given payload is valid.
  *
  * @param  array $payload
  * @return bool
  *
  * @throws \RuntimeException
  */
 protected function validMac(array $payload)
 {
     $bytes = (new SecureRandom())->nextBytes(16);
     $calcMac = hash_hmac('sha256', $this->hash($payload['iv'], $payload['value']), $bytes, true);
     return StringUtils::equals(hash_hmac('sha256', $payload['mac'], $bytes, true), $calcMac);
 }