1

I have a db table called CardNumbers, the data has been encrypted using Crypt::encrypt().

I have a search box that i want to be able to search CardNumbers, but the data is encrypted. How do i decrypt it in my query in mysql.

This is what i am currently using.

$from = INPUT::get('from');
$to = INPUT::get('to');
$email = INPUT::get('searchall');
$appid = INPUT::get('searchall');
$cardS = INPUT::get('searchall');

$data = DB::table('customer')

->when($from && $to, function($query) use ($from, $to) {
                        return $query->whereBetween('AppDate', array($from, $to));
                    })
->when($email, function($query) use ($email){
                        return $query->orWhere('Email', $email);
                    })

                    ->when($appid, function($query) use ($appid){
                        return $query->orWhere('AppID', $appid);
                    })
->when($cardS, function($query) use ($cardS){
                return $query->orWhere('CardNumbers', $cardS);
            })
->get();

return view('customer', compact('data'));

I want to be able to use $cardS

I also tried this to get values of the card details.

$getCard = DB::table('customer')->get();

                foreach($getCard as $key){

                    $cardG = Crypt::decrypt($key->CardNumber);

                    if (strpos($cardG,$cardS) !== false) {
                        $cardS = Crypt::encrypt($cardG) ;
                    }else{$cardS = 0;}

                }
ALCHI
  • 75
  • 1
  • 8

0 Answers0