How can I encrypt the password when creating a new user in axios and php pdo?

When the admin creates a new user, I want to make sure that the password is already encrypted when saving it to the database. How can I do that if I’m using axios + php pdo? Any idea I’m new in vue js/axios/pdo. Can somebody help me with my problem? Here’s my code

  addUser : function() {
            method : "POST",
            url : this.urlRoot + "admin/add_user.php",
            data : {
                username : this.username,
                password : this.password,
                first_name : this.first_name,
                last_name : this.last_name,
                middle_name : this.middle_name,
                contact_no : this.contact_no,
                birth_date : this.birth_date,
                email_address : this.email_address,
                sex :,
                address : this.address,
                is_employed : this.is_employed,
                barangay_id : this.barangay_id,
                user_type_id : this.user_type_id
        }).then(function (response){
            swal("Congrats!", " New user added!", "success");


 public function addUser(){
        $sql = "INSERT INTO `tbl_user`(`user_id`, `username`, `password`, `first_name`, 
        `last_name`, `middle_name`, `contact_no`, `birth_date`, `email_address`, `sex`, 
        `address`, `is_employed`, `barangay_id`, `user_type_id`)";
        $sql .= "VALUES (0,:username, :password, :first_name, :last_name, :middle_name, 
        :contact_no, :birth_date, :email_address, :sex, :address, :is_employed, :barangay_id, 

        $stmt = $this->connection->prepare($sql);

        return $stmt->execute([
            ":username" => $this->username,
            ":password" => $this->password,
            ":first_name" => $this->first_name,
            ":last_name" => $this->last_name,
            ":middle_name" => $this->middle_name,
            ":contact_no" => $this->contact_no,
            ":birth_date" => $this->birth_date,
            ":email_address" => $this->email_address,
            ":sex" => $this->sex,
            ":address" => $this->address,
            ":is_employed" => $this->is_employed,
            ":barangay_id" => $this->barangay_id,
            ":user_type_id" => $this->user_type_id
1 Like

Thanks for the info. i was using Bestcrypto for better encryption. :nerd_face:

Fake Id maker