encrypt() public method

Encrypt the given $string using a cypher and the secret $key
public encrypt ( string $string, string $key ) : string
$string string The string you want to encrypt.
$key string The secret key that will be used to encrypt the string.
return string Encrypted string.
Esempio n. 1
0
 /**
  * Encrypts the given $string using the $key variable as encryption key.
  *
  * @param string $string Raw string that should be encrypted.
  * @param string $key    Security key used for encryption.
  *
  * @return string Encrypted key.
  */
 public function encrypt($string, $key)
 {
     return $this->serviceInstance->encrypt($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);
 }