decrypt() public method

In order to decrypt the string correctly, you must provide the same secret key that was used for the encryption process.
public decrypt ( string $string, string $key ) : string
$string string The string you want to decrypt.
$key string The secret key that was used to encrypt the $string.
return string Decrypted string or false if unable to decrypt (wrong key).
Esempio n. 1
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);
 }
Esempio n. 2
0
 public function testEncryptDecryptFail()
 {
     $crypt = new Crypt();
     $encrypted = $crypt->encrypt('test string', 'some key');
     $result = $crypt->decrypt($encrypted, 'wrong key');
     $this->assertFalse($result);
 }