CodShot
PHP Public

Password Hash and Verify

Hash a password and verify it later with PHP built-in helpers.

#php #password #auth #security
PHP
<?php

$password = $_POST['password'] ?? '';
$hash = password_hash($password, PASSWORD_DEFAULT);

// Later, during login:
$valid = password_verify($password, $hash);

if ($valid) {
    echo 'Password is correct';
} else {
    echo 'Invalid password';
}

Notes

Never store plain text passwords. password_hash automatically uses a safe algorithm.

Snippet actions

CodShot user
CodShot user
Updated: 2026-06-08 14:33
Public snippets
0
Forks
CodShot AI Help
Ask about CodShot features, plans, workspace, AI limits, referrals, and public help topics.
Hi! I can help you understand how CodShot works. What would you like to know?
For account-specific or sensitive issues, please open a support ticket. Open support