1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

How te decrypt in php query syntax

Discussion in 'Community' started by AlfredJK, Mar 16, 2019.

  1. AlfredJK

    AlfredJK Member

    Level: Community
    Hi,
    i build a query like

    Code (Text):
    $myQuery_noodoproep
        ->select(array('prioriteit', 'lifetag_relatie_soort.omschrijving', 'naam', 'telefoonnummer))  
        ->from('lifetag_noodoproep')
        ->join('INNER','lifetag_relatie_soort ON lifetag_noodoproep.relatiesoort = lifetag_relatie_soort.id')
        ->where('lifetag_noodoproep.id_kaart = '.$id_kaart)
        ->order('lifetag_noodoproep.prioriteit')
       
    The field 'telefoonnummer' is encrypted in the database. What should be the syntax in the select statement? I tried on several ways but nothing worked.
     
  2. startpoint

    startpoint Active Member

    Level: Community
    PHP:
    $myQuery_noodoproep
        ->select(array('prioriteit', 'lifetag_relatie_soort.omschrijving', 'naam', AES_DECRYPT('telefoonnummer','your_secret_key')))
        ->from('lifetag_noodoproep')
        ->join('INNER','lifetag_relatie_soort ON lifetag_noodoproep.relatiesoort = lifetag_relatie_soort.id')
        ->where('lifetag_noodoproep.id_kaart = '.$id_kaart)
        ->order('lifetag_noodoproep.prioriteit')
     
  3. AlfredJK

    AlfredJK Member

    Level: Community
    Hi,
    thanks for the reply - when i try this the code result in a error - Call to undefined function AES_DECRYPT()
     
  4. startpoint

    startpoint Active Member

    Level: Community
    Try to decrypt value out of query.
    PHP:
    $tel = AES_DECRYPT('telefoonnummer','your_secret_key');
    echo $tel;
     
  5. AlfredJK

    AlfredJK Member

    Level: Community
    same error :(

    Code (Text):
    $tel = AES_DECRYPT($row->telefoonnummer,'abc');
     
    where abc is the value of the secret parameter in the configuration.php
     
  6. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    You need to put quotes round the AES_DECRYPT() in the field list ...

    Code (Text):

    $myQuery_noodoproep
    ->select(array('prioriteit', 'lifetag_relatie_soort.omschrijving', 'naam', "AES_DECRYPT('telefoonnummer','your_secret_key')"))
        ->from('lifetag_noodoproep')
        ->join('INNER','lifetag_relatie_soort ON lifetag_noodoproep.relatiesoort = lifetag_relatie_soort.id')
        ->where('lifetag_noodoproep.id_kaart = '.$id_kaart)
        ->order('lifetag_noodoproep.prioriteit')
     
    ... otherwise it's being interpreted as a PHP function in the array map.

    -- hugh
     
  7. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    And if you are decrypting something which was encrypted with Fabrik, which uses your J! secret as the key, it'd be ...

    Code (Text):

    $myQuery_noodoproep
    ->select(array('prioriteit', 'lifetag_relatie_soort.omschrijving', 'naam', "AES_DECRYPT('telefoonnummer','" . JFactory::getConfig()->get('secret') . "')"))
        ->from('lifetag_noodoproep')
        ->join('INNER','lifetag_relatie_soort ON lifetag_noodoproep.relatiesoort = lifetag_relatie_soort.id')
        ->where('lifetag_noodoproep.id_kaart = '.$id_kaart)
        ->order('lifetag_noodoproep.prioriteit')
     
    -- hugh
     

Share This Page