Created
January 11, 2024 17:53
-
-
Save lucasburlingham/20e569c74761e62333ed12aceb96e7ad to your computer and use it in GitHub Desktop.
Singlepage SHA256 calculator in PHP using htmx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(isset($_REQUEST["string"])) { | |
printf(hash("sha256", $_REQUEST["string"])); | |
} else { | |
printf("No string provided in request. Please provide a \"string\" to hash. POST & GET are supported."); | |
} | |
?> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>SHA256 Calculator</title> | |
<script src="https://unpkg.com/htmx.org@1.9.10"></script> | |
</head> | |
<body> | |
<form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="POST"> | |
<hr> | |
<label for="string">Input string:</label> | |
<input type="text" name="string" id="string" placeholder="String to hash"> | |
<input type="submit" value="Calculate Hash" hx-post="<?php echo $_SERVER["PHP_SELF"] ?>" hx-swap="outerHTML" hx-target="#output"> | |
</form> | |
<p><b>Output:</b></p> | |
<div id="output"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment