Webiny\Component\Security\Token\CryptDrivers\Crypt\Crypt::encrypt PHP Method

encrypt() public method

Encrypts the given $string using the $key variable as encryption key.
public encrypt ( string $string, string $key ) : string
$string string Raw string that should be encrypted.
$key string Security key used for encryption.
return string Encrypted key.
    public function encrypt($string, $key)
    {
        return $this->serviceInstance->encrypt($string, $key);
    }

Usage Example

Example #1
0
 public function testEncryptDecrypt()
 {
     $crypt = new Crypt('Password');
     $encrypted = $crypt->encrypt('password', 'someSecuredKey12');
     $this->assertNotSame('password', $encrypted);
     $decrypted = $crypt->decrypt($encrypted, 'someSecuredKey12');
     $this->assertSame('password', $decrypted);
 }