<?php
defined('BASEPATH') OR exit('No direct script access allowed');

function enc($tmp){
    $CI =& get_instance();
    return base64_encode($CI->encrypt->encode($tmp));
}

function dec($tmp){
    $CI =& get_instance();
    return $CI->encrypt->decode(base64_decode($tmp));
}

function clear_text($text){
    return str_replace("'", "''", $text);
}

function clear_apostrophe($text){
    return str_replace("''", "'", $text);
}

function persen($val){
    return str_replace('.',',',round($val * 100,2)).' %';
}
function set_rupiah($int){
    $return = number_format($int, 2, ',', '.').",-";
    if ($int==0) {
        $return = '-';
    }
    return $return;
}

function strToHex($string){
    $hex = '';
    for ($i=0; $i<strlen($string); $i++){
        $ord = ord($string[$i]);
        $hexCode = dechex($ord);
        $hex .= substr('0'.$hexCode, -2)." ";
    }
    return strToUpper($hex);
}