How te decrypt in php query syntax

AlfredJK

Member
Hi,
i build a query like

Code:
$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.
 
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')
 
Hi,
thanks for the reply - when i try this the code result in a error - Call to undefined function AES_DECRYPT()
 
Try to decrypt value out of query.
PHP:
$tel = AES_DECRYPT('telefoonnummer','your_secret_key');
echo $tel;
 
same error :(

Code:
$tel = AES_DECRYPT($row->telefoonnummer,'abc');

where abc is the value of the secret parameter in the configuration.php
 
You need to put quotes round the AES_DECRYPT() in the field list ...

Code:
$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
 
And if you are decrypting something which was encrypted with Fabrik, which uses your J! secret as the key, it'd be ...

Code:
$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
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top