public function out($v,$head=array()) { return $this->db()->out($v,$head); }
- public function infos() {
- debug('TODEL');
- return ['TODEL'];
- # TODEL - NB 07.09.16
- $this->type();
- return
- [
- "name" => $this->name,
- "type" => $this->type,
- #"fields" => count($this->fields()),
- #"count" => $this->count(),
- #"sql_name" => $this->sql_name(),
- ]
- +( isset($this->engine) ? ["engine" => $this->engine] : [] )
- +( isset($this->created) ? ["created" => $this->created] : [] )
-# NB 07.09.16 +( self::p('fields') ?['fields' => count($this->fields())] : [] )
-# NB 07.09.16 +( self::p('count') ?['count' => $this->count()] : [] )
-# NB 07.09.16 +( self::p('sql') ? ['sql' => $this->sql()] : [] )
- ;
- }
-
private function url_referer($default='') {
if (self::p('referer')) {
return urldecode($this->p('referer'));
require_once(realpath(dirname(__FILE__).'/functions.php'));
#$nb = new NB(); debug($nb->test());
#if (!defined('NB_PARAMS')) define('NB_PARAMS',$_REQUEST);
-if (class_exists('NB')) return;
+#if (class_exists('NB')) return;
class NB {
const ROOT_DIR = NB_ROOT;
$mb_diff=mb_strlen($input, $encoding)-strlen($input);
return str_pad($input,$pad_length-$mb_diff,$pad_string,$pad_type);
}
+
+ public static function encrypt($key,$value) {
+ #$key = hash("SHA256", 'your pass', true); //we want a 32 byte binary blob
+ $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
+ $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
+ return base64_encode($iv . mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $value, MCRYPT_MODE_CBC, $iv));
+ }
+
+ public static function decrypt($key,$value) {
+ $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
+ $value = base64_decode($value);
+ return rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, substr($value, $iv_size), MCRYPT_MODE_CBC, substr($value, 0, $iv_size)));
+ }
+
} # < Class
+
+#return;
+if (!count($argv) or (string)$argv[1] != 'test') return;
+$value = 'Hello World !';
+#$value = file_get_contents('/etc/hosts');
+$key = hash("SHA256", '5587eeb68760aa0ed7d2d1212d0829c3', true); //we want a 32 byte binary blob
+#$key = '5587eeb68760aa0ed7d2d1212d0829c3';
+#$key = '76a553babab7a62b7935d9a10f73777bf57b043c9d0f1fc22ea51dd9484154bc91afafd0f92e773e590ad05ebca9aec3fac11ebada7e517c78d32790e5a8f3ed';
+$enc = nb::encrypt($key,$value);
+echo ''
+ ."key : $key\n"
+ ."enc : $enc\n"
+ ."value: ".nb::decrypt($key,$enc) ."\n"
+;
?>
'txt' => array(
'col' => self::p('col',' : '),
'sep' => self::p('sep',"\n"),
- 'eol' => self::p('eol',"\n"),
+ 'eol' => self::p('eol',"--\n"),
),
'csv' => array(
#or !isset($o['head'])
) return;
- if (self::type_call('head',$o,$head)) $o['out_count']++;
- if (isset($o['eol'])) echo $o['eol'];
+ if (self::type_call('head',$o,$head)) {
+ $o['out_count']++;
+ if (isset($o['eol'])) echo $o['eol'];
+ }
return $head;
}