From: root Date: Thu, 17 Aug 2017 14:22:57 +0000 (+0100) Subject: ssha512 X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=5b5bbe9b500925fae3bd9569b1fcdd9d3f381e5d;p=nb.git ssha512 --- diff --git a/lib/php/db.php b/lib/php/db.php index 019560ea..56603c7c 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -1306,6 +1306,12 @@ class Db extends nb { ],$opt)); } + public function ssha512_password($password='',$salt='') { + if (empty($password)) return $password; + if ($salt === '') $salt = substr(str_shuffle(str_repeat('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',4)),0,4); + $password = '{SSHA512}' . base64_encode(hash('sha512', $password . $salt). $salt); + return $password; + } public function ssha_password($password='') { if (empty($password)) return $password; $salt = substr(str_shuffle(str_repeat('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',4)),0,4); diff --git a/www/dbq/dbq.php b/www/dbq/dbq.php index ecf9834c..73cb5231 100644 --- a/www/dbq/dbq.php +++ b/www/dbq/dbq.php @@ -482,6 +482,20 @@ class DbQ extends nb { exit; } + public function ssha512_password($password='') { + if ($password=='') { + if ($password=='') $password = $this->params['table']; + if ($password=='' and !empty($_POST['password'])) $password = $_POST['password']; + if ($this->is_html) echo << + + + +EOF; + } + return $this->db->ssha512_password($password); + } + public function ssha_password($password='') { if ($password=='') { if ($password=='') $password = $this->params['table']; @@ -785,6 +799,7 @@ EOF; [ 'databases', 'List others databases' ], [ 'cryptkey', 'Generate a random encryption key' ], [ 'ssha_password', 'Encrypt a password' ], + [ 'ssha512_password', 'Encrypt a password' ], [ 'logout', 'Clear Basic Auth' ], [ 'status', 'Status infos page' ], ],['command','description'],function(&$r) { @@ -814,6 +829,9 @@ EOF; } elseif ($action == 'ssha_password') { $this->page($this,'ssha_password'); + } elseif ($action == 'ssha512_password') { + $this->page($this,'ssha512_password'); + } elseif ($action == 'cryptkey') { $this->page($this->db,'cryptkey',['key']);