<?php

namespace App\Helper;

class Encryption
{
    static function encrypt($data)
    {
        $cipher = 'AES-256-CBC';
        $iv = \Str::random(16); // Generate a random IV
        // Encrypt the data
        $encryptedData = openssl_encrypt($data, $cipher, 
        ApiHelper::$ENCRYPT_KEY, 0, $iv);
        // Return encrypted data along with the IV
        return [
            'encryptedData' => $encryptedData,
            'iv' => $iv
        ];
    }
}
