public function decryptEntityField(EntityInterface $entity, string $field)
    {
        if (!$this->canDecryptField($entity, $field)) {
            return null;
        }

        $encryptionKey = $this->getConfig('encryptionKey');
        $base64 = $this->getConfig('base64');
        $encoded = $entity->get($field);
        if (empty($encoded) || $encoded === false) {
            return null;
        }

        if ($base64 === true) {
            $encoded = base64_decode($encoded, true);
            if ($encoded === false) {
                return null;
            }
        }
        $decrypted = Security::decrypt($encoded, $encryptionKey);
        if ($decrypted === false) {
            throw new RuntimeException("Unable to decypher `{$field}`. Check your enryption key.");
        }

        return $decrypted;
    }
public function decryptEntityField(EntityInterface $entity, string $field)
    {
        if (!$this->canDecryptField($entity, $field)) {
            return null;
        }

        $encryptionKey = $this->getConfig('encryptionKey');
        $base64 = $this->getConfig('base64');
        $encoded = $entity->get($field);
        if (empty($encoded) || $encoded === false) {
            return null;
        }

        if ($base64 === true) {
            $encoded = base64_decode($encoded, true);
            if ($encoded === false) {
                return null;
            }
        }
        $decrypted = Security::decrypt($encoded, $encryptionKey);
        if ($decrypted === false) {
            throw new RuntimeException("Unable to decypher `{$field}`. Check your enryption key.");
        }

        return $decrypted;
    }
public function decryptEntityField ( EntityInterface $ entity , string $ field ) { if ( ! $ this -> canDecryptField ( $ entity , $ field ) ) { return null ; } $ encryptionKey = $ this -> getConfig ( 'encryptionKey' ) ; $ base64 = $ this -> getConfig ( 'base64' ) ; $ encoded = $ entity -> get ( $ field ) ; if ( empty ( $ encoded ) || $ encoded === false ) { return null ; } if ( $ base64 === true ) { $ encoded = base64_decode ( $ encoded , true ) ; if ( $ encoded === false ) { return null ; } } $ decrypted = Security :: decrypt ( $ encoded , $ encryptionKey ) ; if ( $ decrypted === false ) { throw new RuntimeException ( "Unable to decypher `{$field}`. Check your enryption key." ) ; } return $ decrypted ; }
Returns the decrypted field value. Assumes that the field is actually encrypted.

@param \Cake\Datasource\EntityInterface $entity Entity.
@param string $field Field name.
@return mixed|null Credentials or null when empty.
Returns the decrypted field value . Assumes that the field is actually encrypted .