Inheritance: use trait Webiny\Component\StdLib\ComponentTrait, use trait Webiny\Component\StdLib\StdLibTrait
Example #1
0
 public function testEncryptDecryptFail()
 {
     $crypt = new Crypt();
     $encrypted = $crypt->encrypt('test string', 'some key');
     $result = $crypt->decrypt($encrypted, 'wrong key');
     $this->assertFalse($result);
 }
 public function testDecryptUserData()
 {
     \Webiny\Component\Crypt\Crypt::setConfig(__DIR__ . '/CryptDrivers/Crypt/CryptExampleConfig.yaml');
     $user = new UserMock();
     $user->populate('uname', 'pwd', [new Role('ROLE_MOCK')], false);
     $crypt = new TokenCryptMock(new ConfigObject([]));
     $instance = new TokenStorageMock();
     $instance->setCrypt($crypt);
     $result = $instance->encryptUserData($user);
     $tokenData = $instance->decryptUserData($result);
     $this->assertInstanceOf('\\Webiny\\Component\\Security\\Token\\TokenData', $tokenData);
     $this->assertSame('uname', $tokenData->getUsername());
 }
Example #3
0
 /**
  * Decrypts the given $string that was encrypted with the $key.
  *
  * @param string $string Encrypted string.
  * @param string $key    Key used for encryption.
  *
  * @return string Decrypted string.
  */
 public function decrypt($string, $key)
 {
     return $this->serviceInstance->decrypt($string, $key);
 }
Example #4
0
 /**
  * Verify if the $password matches the $hash.
  *
  * @param string $password
  * @param string $hash
  *
  * @return bool True if $password matches $hash. Otherwise false is returned.
  */
 public function verifyPasswordHash($password, $hash)
 {
     return $this->instance->verifyPasswordHash($password, $hash);
 }
Example #5
0
 public function setUp()
 {
     \Webiny\Component\Crypt\Crypt::setConfig(__DIR__ . '/CryptExampleConfig.yaml');
 }
Example #6
0
 /**
  * Get the name of bridge library which will be used as the driver.
  *
  * @return string
  */
 static function getLibrary()
 {
     return \Webiny\Component\Crypt\Crypt::getConfig()->get('Bridge', self::$library);
 }