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()); }
/** * 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); }
/** * 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); }
public function setUp() { \Webiny\Component\Crypt\Crypt::setConfig(__DIR__ . '/CryptExampleConfig.yaml'); }
/** * 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); }