11-24-2019, 12:39 AM
I'm very new to Codeigniter. It's only hobby, but I run it on Apache with PHP. I'm getting used to PHP and Codeigniter. My one class was in 2007 and it entailed Access, VBA, Visual Basic and C#. Which should explain the issue ; (I was able to pull a sample MySQL table from a model file to a view file, but seems odd $data going to the view file as nothing.) I eventually want to encrypt all files in the folders and pass them through the model & control folder like containers.
I enabled the ssl extension in PHP. I made a model file that us supposed to be my first go at PHP cryptography. The control seems like it grabs the model file and the view file loads, but nothing. I made the folders red text and file names blue.
I apologize if it's more a PHP forum topic.
view folder:
test.php =
<?php
?>
Model:
Pass1_script.php =
<?php
class Pass1_script extends CI_Model {
function crypt1() {
$plaintext = "Figure out encryption";
$key = "1234";
$cipher = "aes-128-gcm";
if (in_array($cipher, openssl_get_cipher_methods()))
{
$ivlen = openssl_cipher_iv_length($cipher);
$iv = openssl_random_pseudo_bytes($ivlen);
$ciphertext = openssl_encrypt($plaintext, $cipher, $key, $options=0, $iv, $tag);
Return('$ciphertext');
}
}
}
?>
Control:
practice.php =
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class practice extends CI_Controller {
function test() {
$this->load->model('Pass1_script');
$data['$ciphertext'] = $this->Pass1_script->crypt1();
$this->load->view('test', $data);
}
}
I enabled the ssl extension in PHP. I made a model file that us supposed to be my first go at PHP cryptography. The control seems like it grabs the model file and the view file loads, but nothing. I made the folders red text and file names blue.
I apologize if it's more a PHP forum topic.
view folder:
test.php =
<?php
?>
Model:
Pass1_script.php =
<?php
class Pass1_script extends CI_Model {
function crypt1() {
$plaintext = "Figure out encryption";
$key = "1234";
$cipher = "aes-128-gcm";
if (in_array($cipher, openssl_get_cipher_methods()))
{
$ivlen = openssl_cipher_iv_length($cipher);
$iv = openssl_random_pseudo_bytes($ivlen);
$ciphertext = openssl_encrypt($plaintext, $cipher, $key, $options=0, $iv, $tag);
Return('$ciphertext');
}
}
}
?>
Control:
practice.php =
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class practice extends CI_Controller {
function test() {
$this->load->model('Pass1_script');
$data['$ciphertext'] = $this->Pass1_script->crypt1();
$this->load->view('test', $data);
}
}