Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

maytham's avatar

Hashing confusion

Hey Guys,

I am passing form value to store function, works perfectly with out hash:

    public function store()
    {
        $this->registrationForm->validate(Input::all());

        $user = User::create(
            Input::only('username', 'email', 'password')
        );

        Auth::login($user);

        return Redirect::to('profile');
    }

Now the moment I add hash like this

    public function store()
    {
        $this->registrationForm->validate(Input::all());

        $user = User::create(
            Input::only('username', 'email', Hash::make('password'))
        );

        Auth::login($user);

        return Redirect::to('profile');
    }

1- I get the output of password as NULL in the database, what I am doing wrong?

2- In form validation, how to make password minimum length requirement?

Thanks in advance.

0 likes
3 replies
aliqsyed's avatar
Level 29

It's not working because you are hashing the key instead of hashing the actual password. Try using the following code

public function store()
    {
        $this->registrationForm->validate(Input::all());
        $data =  Input::only('username', 'email', 'password');
        $data['password'] = Hash::make($data['password']);
        $user = User::create($data);

        Auth::login($user);

        return Redirect::to('profile');
    }

for password length you can use this in your $rules array

 'password' => 'required|min:8',
1 like

Please or to participate in this conversation.