コード例 #1
0
ファイル: Tools.php プロジェクト: andyburton/sonic-framework
 /**
  * Crypt
  */
 public function crypt()
 {
     // Set variables
     $original = '';
     $type = '';
     $crypt = '';
     // If the form is submitted
     if (isset($_POST['crypt'])) {
         // Get variables
         $original = $_POST['original'];
         $type = $_POST['type'];
         // Crypt
         switch ($type) {
             case 'md5':
                 $crypt = md5($original);
                 break;
             case 'sha1':
                 $crypt = sha1($original);
                 break;
             case 'sha256':
                 $crypt = \Sonic\Resource\Crypt::_sha256($original);
                 break;
             case 'bcrypt':
                 $crypt = \Sonic\Resource\User::_Hash($original);
                 break;
         }
     }
     // Set template variables
     $this->view->assign('original', $original);
     $this->view->assign('type', $type);
     $this->view->assign('crypt', $crypt);
     $this->view->assign('options', ['bcrypt' => 'bcrypt', 'md5' => 'md5', 'sha1' => 'sha1', 'sha256' => 'sha256']);
 }