Skip to content

Instantly share code, notes, and snippets.

@sskylar
Last active August 28, 2018 18:28
Show Gist options
  • Save sskylar/7b6ee7c36158a79a3316 to your computer and use it in GitHub Desktop.
Save sskylar/7b6ee7c36158a79a3316 to your computer and use it in GitHub Desktop.
Simple password protection using a md5 hashed slug in Siteleaf (note: this is not intended for high security, only to stop casual visitors)
<form>
<input id="password" type="password"/>
<button>Submit</button>
</form>
// uses https://code.google.com/p/crypto-js/
$("form").submit(function(e) {
// recreate hashed slug
var hashed_slug = CryptoJS.MD5($('#password').val());
// attempt to load in contents
$("body").load("/clients/"+hashed_slug, function(response, status, xhr) {
// if password was entered incorrectly this will be a 404
if (status == "error") alert("Incorrect password");
});
e.preventDefault();
});
---
permalink: "/clients/5ebe2294ecd0e0f08eab7690d2a6ee69/"
sitemap: false
---
You correctly guesed the password: "secret"
@sskylar
Copy link
Author

sskylar commented Oct 30, 2017

Use a tool like this to generate md5 hashes: http://www.miraclesalad.com/webtools/md5.php

e.g. secret becomes 5ebe2294ecd0e0f08eab7690d2a6ee69

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment