return str_pad($input,$pad_length-$mb_diff,$pad_string,$pad_type);
}
+ public static function cryptkey($length=32) {
+ return bin2hex(mcrypt_create_iv($length, MCRYPT_DEV_URANDOM));
+ }
+
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));
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 = hash("MD5", '5587eeb68760aa0ed7d2d1212d0829c3'); //we want a 32 byte binary blob
#$key = '5587eeb68760aa0ed7d2d1212d0829c3';
#$key = '76a553babab7a62b7935d9a10f73777bf57b043c9d0f1fc22ea51dd9484154bc91afafd0f92e773e590ad05ebca9aec3fac11ebada7e517c78d32790e5a8f3ed';
$enc = nb::encrypt($key,$value);
'db' => 'ls',
'table' => 'ls',
'action' => 'ls',
+ 'params' => '',
]);
#var_export($params);
$ext = $params['format'];
#Page::pdef('out',1);
$Page = new Page([
'css' => '/default.css',
- 'title' => join(' ',array_unique(array_slice(array_values($params),1))),
+ 'title' => join(' ',array_filter(array_unique(array_slice(array_values($params),1)),function($v){if ($v!=='ls') return $v;})),
]);
$params['ext'] = $ext;
#
# Db actions
if ($params['table'] == 'help') {
- #$this->out->rows($format,$rows,$head);
$Db->out([
[ 'help', 'This help' ],
[ 'ls', 'List tables' ],
return $Page->end();
} elseif ($params['table'] == 'ls') {
- /*
- bye('zaza');
- $Table->row_parse_post = function(&$row) use($Page) {
- debug($row);
- $row['name'] = '';
- #$Page->tag('a',$row['name']);
- };
- */
- #$Db->action('db.tables');
$Db->out($Db->tables_rows(),[],['row_parse_post'=>function(&$r) use ($Page,$params) {
$r['name'] = $Page->tag('a',$r['name'],'href="'.$params['db'].'/'.$r['name'].'.'.$params['ext'].'"');
}]);
[ 'fields', 'List fields' ],
],['command','description'],
['row_parse_post'=>function(&$r) use ($Page,$params) {
- $r['command'] = $Page->tag('a',$r['command'],'href="'.$r['command'].'.'.$params['ext'].'"');
+ $r['command'] = $Page->tag('a',$r['command'],'href="'.($r['command']=='ls'?'../'.$params['table']:$r['command']).'.'.$params['ext'].'"');
}]);
return $Page->end();