-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpassword_tool.php
More file actions
76 lines (72 loc) · 3.11 KB
/
password_tool.php
File metadata and controls
76 lines (72 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
// Simple utility to generate and verify hashes
$hash_generated = "";
$verify_result = "";
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Action 1: Generate Hash
if (isset($_POST['generate'])) {
$plain_text = $_POST['plain_password'];
$hash_generated = password_hash($plain_text, PASSWORD_DEFAULT);
}
// Action 2: Verify Password against Hash
if (isset($_POST['verify'])) {
$plain_text = $_POST['check_password'];
$existing_hash = $_POST['existing_hash'];
if (password_verify($plain_text, $existing_hash)) {
$verify_result = "<div class='alert alert-success'>✅ MATCH! This password is correct for this hash.</div>";
} else {
$verify_result = "<div class='alert alert-danger'>❌ NO MATCH! This password does NOT belong to this hash.</div>";
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Password Utility Tool</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="bg-light p-5">
<div class="container" style="max-width: 800px;">
<h2 class="mb-4">PHP Password Utility</h2>
<p class="text-muted">Note: Passwords are hashed using BCrypt. They cannot be "decoded," only verified.</p>
<div class="row">
<!-- GENERATOR -->
<div class="col-md-6">
<div class="card shadow-sm mb-4">
<div class="card-body">
<h5>Generate New Hash</h5>
<form method="POST">
<input type="text" name="plain_password" class="form-control mb-2" placeholder="Enter plain text password" required>
<button name="generate" class="btn btn-primary w-100">Create Hash</button>
</form>
<?php if($hash_generated): ?>
<div class="mt-3">
<small class="text-muted">Your New Hash (Copy this to Database):</small>
<textarea class="form-control" rows="3" readonly><?php echo $hash_generated; ?></textarea>
</div>
<?php endif; ?>
</div>
</div>
</div>
<!-- VERIFIER -->
<div class="col-md-6">
<div class="card shadow-sm mb-4">
<div class="card-body">
<h5>Verify Password</h5>
<form method="POST">
<input type="text" name="check_password" class="form-control mb-2" placeholder="Plain text password" required>
<textarea name="existing_hash" class="form-control mb-2" placeholder="Paste the hash here" required></textarea>
<button name="verify" class="btn btn-secondary w-100">Check Match</button>
</form>
<div class="mt-3"><?php echo $verify_result; ?></div>
</div>
</div>
</div>
</div>
<div class="text-center mt-3">
<a href="index.php" class="btn btn-link text-decoration-none">← Back to System</a>
</div>
</div>
</body>
</html>