102 lines
5.4 KiB
PHP
102 lines
5.4 KiB
PHP
<?php
|
|
// require_once ('.hta_config/siliconpin_sp.php');
|
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|
|
|
$md5_hash = md5($_POST["md5-text"]);
|
|
try {
|
|
$db = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
|
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
$stmt = $db->prepare("INSERT INTO md5_data (md5, value) VALUES (:md5, :value)");
|
|
$stmt->bindParam(':md5', $md5_hash);
|
|
$stmt->bindParam(':value', $_POST["md5-text"]);
|
|
$stmt->execute();
|
|
echo ' <div class="diZContainer diZmxAuto">
|
|
<h2 class="diZBorderBottom">Generate MD5 Hash</h2>
|
|
<p>The MD5 Hash Generator tool allows you to quickly and easily generate an MD5 hash from any text input. This is useful for creating checksums, storing passwords securely, or any other application where a unique hash representation of your data is needed.</p>
|
|
<div class="diZMaxW600 diZmxAuto diZmy20 toolsSection">
|
|
<div class="diZFlexColumn diZJustifyCenter ">
|
|
<div>
|
|
<p>Converted MD5: </p>
|
|
<p id="copied-notice"></p>
|
|
<div class="diZFlexColumn">
|
|
<input id="output" type="text" readonly value="'.$md5_hash.'" /><br>
|
|
<button class="diZmxAuto" id="copyButton" onclick="copyOutputText()"><span>Copy</span></button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>';
|
|
echo '
|
|
<script>
|
|
function copyOutputText() {
|
|
const outputText = document.getElementById(\'output\').value;
|
|
const textarea = document.createElement(\'textarea\');
|
|
textarea.value = outputText;
|
|
document.body.appendChild(textarea);
|
|
textarea.select();
|
|
document.execCommand(\'copy\');
|
|
document.body.removeChild(textarea);
|
|
document.getElementById(\'copied-notice\').style.display = \'block\';
|
|
document.getElementById(\'copied-notice\').innerHTML = \'MD5 copied to clipboard!\';
|
|
}
|
|
</script>';
|
|
// echo json_encode(array('success' => true, 'message' => 'Data inserted successfully'));
|
|
// echo '<script>window.location.href="/admin/add-content";</script>';
|
|
} catch (PDOException $e) {
|
|
echo json_encode(array('success' => false, 'message' => 'Database error: ' . $e->getMessage()));
|
|
exit();
|
|
}
|
|
}else{
|
|
echo '<section class="diZContainer diZmxAuto">
|
|
<h2 class="diZBorderBottom">Generate MD5 Hash</h2>
|
|
<div class="diZMaxW600 diZmxAuto diZmy20 toolsSection">
|
|
<form method="post" class="diZFlexColumn diZJustifyCenter "><br>
|
|
<label for="md5-text" class="">Enter Text Convert to MD5:</label><br>
|
|
<textarea name="md5-text" id="md5-text" rows="10"></textarea><br>
|
|
<button class="diZmxAuto" type="submit"><span>Generate MD5 Hash</span></button>
|
|
</form>
|
|
</div>
|
|
</section>';
|
|
}
|
|
?>
|
|
<div class="diZContainer diZmxAuto">
|
|
<h3>Usage:</h3>
|
|
<ul>
|
|
<li><strong>Enter Text:</strong> Input your desired text into the text area provided.</li>
|
|
<li><strong>Generate MD5 Hash:</strong> Click the "Generate MD5 Hash" button to convert the text into an MD5 hash.</li>
|
|
<li><strong>Copy Hash:</strong> Once generated, the hash will appear in the output text area. Click the "Copy" button to copy it to your clipboard.</li>
|
|
<li><strong>Paste and Use:</strong> Paste the copied hash directly into your application, database, or any other place where you need an MD5 hash.</li>
|
|
</ul>
|
|
|
|
<h3>Features:</h3>
|
|
<ul>
|
|
<li>Generates a unique MD5 hash from any input text.</li>
|
|
<li>Displays the generated hash in a read-only text area for easy copying.</li>
|
|
<li>Provides a "Copy" button to quickly copy the generated hash to the clipboard.</li>
|
|
<li>Includes error handling to manage database insertion issues gracefully.</li>
|
|
</ul>
|
|
|
|
<h3>Example Use Cases:</h3>
|
|
<ul>
|
|
<li>Web developers creating checksums for file verification.</li>
|
|
<li>Security professionals storing passwords securely in a database.</li>
|
|
<li>Software engineers ensuring data integrity by generating unique hashes for sensitive data.</li>
|
|
</ul>
|
|
</div>
|
|
|
|
|
|
|
|
<!-- <script>
|
|
function copyOutputText() {
|
|
const outputText = document.getElementById('output').value;
|
|
const textarea = document.createElement('textarea');
|
|
textarea.value = outputText;
|
|
document.body.appendChild(textarea);
|
|
textarea.select();
|
|
document.execCommand('copy');
|
|
document.body.removeChild(textarea);
|
|
document.getElementById('copied-notice').style.display = 'block';
|
|
document.getElementById('copied-notice').innerHTML = 'Output text copied to clipboard!';
|
|
}
|
|
</script> -->
|