<?php

defined('BASEPATH') or exit('No direct script access allowed');

if( !function_exists('random_bytes') )
{
    function random_bytes($length = 16)
    {
        $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
        $characters_length = strlen($characters);
        $output = '';
        for ($i = 0; $i < $length; $i++)
            $output .= $characters[rand(0, $characters_length - 1)];

        return $output;
    }
}

class MY_Model extends CI_Model
{
	public $table_prefix = "";
	public $tbl;
	public $payment_method = [
		'octopus' => 0,
	];
	public $status = [
		0 => '不啟用',
		1 => '啟用',
	];

	public function __construct()
	{
		parent::__construct();
	}

	public function random_string ($length)
	{
		$byte = random_bytes(floor($length / 2));
		return bin2hex($byte);
	}
}
