public function testDecryption() { $crypto = new LibsodiumSymmetricCrypto($this->secret); $encrypted = <<<'HEX' 5f37653f690be967cd4c64bf7821db2fb98b8db6a8784e1c466921f38dd8c309d9b7ee1eb27b26c6d40c02d9b65838c0f93c74d99acb1ffbf8600d1033a14953a3ba8d7e3d1e71020b978fc14d59a659e5ba192be2102f2fb2ce6b4faf97f2195c5a HEX; $expected = 'By the power of Grayskull!'; $cleartext = $crypto->decrypt(hex2bin($encrypted)); $this->assertSame($expected, $cleartext); }
/** * @inheritDoc */ public function decrypt($encrypted) { $payload = $this->uriSafeDecode($encrypted); if (!$payload) { return null; } try { $unencrypted = $this->crypto->decrypt($payload); } catch (CryptoException $ex) { return null; } return $unencrypted; }