]> git.nbdom.net Git - nb.git/commitdiff
ssha512
authorroot <sys@15gifts.com>
Thu, 17 Aug 2017 14:22:57 +0000 (15:22 +0100)
committerroot <sys@15gifts.com>
Thu, 17 Aug 2017 14:22:57 +0000 (15:22 +0100)
lib/php/db.php
www/dbq/dbq.php

index 019560eaa3289e2235d93236bd1f668654d7323a..56603c7c6c904a462069d65950e4b355a3672b58 100644 (file)
@@ -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);
index ecf9834c14c4a7d3e780c9bab5ed8a5716716f2a..73cb523106d0de827b03ecbde71c548c71e418fd 100644 (file)
@@ -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
+<form action="$this->uri" method="post" class="block" style="padding:1.5em">
+<label>Password</label><input type="text" name="password" value="$password" />
+<input type="submit" />
+</form>
+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']);