Beispiel #1
0
 public function testEncrypt()
 {
     $string = 'my big fat secret';
     $encrypted = $this->encryption->encrypt($string);
     $decrypted = $this->encryption->decrypt($encrypted);
     $this->assertSame($string, $decrypted);
 }
Beispiel #2
0
 /**
  * @param $key
  * @return string
  * @throws UnavailableException
  */
 public function get($key)
 {
     if (isset($this->data[$key])) {
         return $this->encryption->decrypt($this->data[$key]);
     } else {
         throw new MissingException("Key '{$key}' not found");
     }
 }
Beispiel #3
0
 /**
  * @param $key
  * @return string
  * @throws MissingException
  * @throws UnavailableException
  */
 public function get($key)
 {
     try {
         $encrypted = $this->client->get($key);
         if (empty($encrypted)) {
             throw new MissingException("No token found for {$key}");
         }
         // decrypt to token after retrieval
         return $this->encryption->decrypt($encrypted);
     } catch (ServerException $ex) {
         throw new UnavailableException($ex->getMessage());
     }
 }