<?php // Verileri okuyan ve şifresini çözen fonksiyon function oku($fileName, $secretKey, $encryptionMethod) { $fileContent = file_get_contents($fileName); $fileData = json_decode($fileContent, true); $iv = base64_decode($fileData['iv']); $decryptedData = openssl_decrypt(base64_decode($fileData['data']), $encryptionMethod, $secretKey, 0, $iv); return json_decode($decryptedData, true); } // Verileri yazan ve şifreleyen fonksiyon function yaz($fileName, $data, $secretKey, $encryptionMethod) { $jsonData = json_encode($data); $ivLength = openssl_cipher_iv_length($encryptionMethod); $iv = openssl_random_pseudo_bytes($ivLength); $encryptedData = openssl_encrypt($jsonData, $encryptionMethod, $secretKey, 0, $iv); $encryptedFileContent = json_encode([ 'data' => base64_encode($encryptedData), 'iv' => base64_encode($iv), ]); file_put_contents($fileName, $encryptedFileContent); } //VERİTABANI BAĞLANTI $fileName = 'lisanslar.txt'; // tablo adı $secretKey = "Alp123*_."; $encryptionMethod = "AES-256-CBC"; //OKUMA - SELECT $data = oku($fileName, $secretKey, $encryptionMethod); print_r($data); //YAZMA - INSERT $data[] = ["name" => "Alperen", "price" => 1000]; writeData($fileName, $data, $secretKey, $encryptionMethod); //SİLME - DELETE $id = 0; //dizi index no unset($data[$id]); $data = array_values($data); writeData($fileName, $data, $secretKey, $encryptionMethod); //GÜNCELLEME - UPDATE $id = 0;//güncellenecek veri id $name= "Mehmet"; //yeni isim $data[$id]['name'] = $name; writeData($fileName, $data, $secretKey, $encryptionMethod);