title: how to encrypt password with hash sha512 in codeigniter while uploading to db
body: <p>I want to encrypt my password using hashing when submitting data to the database kindly guide me to where to change the code</p>
  <p>Can anyone help me out to find the best encryption method for Codeigniter?</p>
  <pre><code>public function register(){ 
      if($this-&gt;isUserLoggedIn){ 
            redirect('users/account'); 
           } 
      $data = array(); 
      if($this-&gt;session-&gt;userdata('success_msg')){ 
          $data['success_msg'] = $this-&gt;session-&gt;userdata('success_msg'); 
          $this-&gt;session-&gt;unset_userdata('success_msg'); 
      } 
      if($this-&gt;session-&gt;userdata('error_msg')){ 
          $data['error_msg'] = $this-&gt;session-&gt;userdata('error_msg'); 
          $this-&gt;session-&gt;unset_userdata('error_msg'); 
      } 
      if($this-&gt;input-&gt;post('signupSubmit')){ 
          $this-&gt;form_validation-&gt;set_rules('first_name', 'First Name', 'trim|required'); 
          $this-&gt;form_validation-&gt;set_rules('last_name', 'Last Name', 'trim|required'); 
          $this-&gt;form_validation-&gt;set_rules('mobile_no', 'Mobile', 'required|min_length[10]|max_length[10]|regex_match[/^[0-9]{10}$/]|callback_mobile_no_check'); 
          $this-&gt;form_validation-&gt;set_rules('email', 'Email', 'trim|required|valid_email'); 
          $this-&gt;form_validation-&gt;set_rules('password', 'password', 'required'); 
          $this-&gt;form_validation-&gt;set_rules('conf_password', 'confirm password', 
  'required|matches[password]'); 
   $userData = array( 
              'first_name' =&gt; strip_tags($this-&gt;input-&gt;post('first_name')), 
              'last_name' =&gt; strip_tags($this-&gt;input-&gt;post('last_name')), 
              'email' =&gt; strip_tags($this-&gt;input-&gt;post('email')), 
              'password' =&gt; strip_tags($this-&gt;input-&gt;post('password')), 
              'gender' =&gt; $this-&gt;input-&gt;post('gender'), 
              'mobile_no' =&gt; strip_tags($this-&gt;input-&gt;post('mobile_no')) 
          ); 
              if($this-&gt;form_validation-&gt;run() == true){ 
              $insert = $this-&gt;users_model-&gt;insert($userData); 
              if($insert){ 
                  $this-&gt;session-&gt;set_userdata('success_msg', 'Your account registration has been successful. Please login to your account.'); 
                  redirect('users/login'); 
              }else{ 
                  $data['error_msg'] = 'Some problems occured, please try again.'; 
              } 
          }else{ 
              $data['error_msg'] = 'Please fill all the mandatory fields.'; 
          } 
      }
      // Load view 
      $data['pvalue'] = array('view'=&gt;'login_view','pgTitle'=&gt;'Log In');
      $this-&gt;loadView($data);
      
      
  }
  </code></pre>