Chris@0: state = $state; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Gets the private key. Chris@0: * Chris@0: * @return string Chris@0: * The private key. Chris@0: */ Chris@0: public function get() { Chris@0: if (!$key = $this->state->get('system.private_key')) { Chris@0: $key = $this->create(); Chris@0: $this->set($key); Chris@0: } Chris@0: Chris@0: return $key; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Sets the private key. Chris@0: * Chris@0: * @param string $key Chris@0: * The private key to set. Chris@0: */ Chris@0: public function set($key) { Chris@0: return $this->state->set('system.private_key', $key); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Creates a new private key. Chris@0: * Chris@0: * @return string Chris@0: * The private key. Chris@0: */ Chris@0: protected function create() { Chris@0: return Crypt::randomBytesBase64(55); Chris@0: } Chris@0: Chris@0: }