2017-10-02 11:14:50 +02:00

52 lines
1.6 KiB
HTML

<!doctype html>
<html class="staticrypt-html">
<head>
<meta charset="utf-8">
<title>{{ gallery.title }} · {{ settings.title }}</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- do not cache this page -->
<meta http-equiv="cache-control" content="max-age=0"/>
<meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="expires" content="0"/>
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT"/>
<meta http-equiv="pragma" content="no-cache"/>
<link type="text/css" rel="stylesheet" href="../static/css/style-page.css" media="screen,projection"/>
</head>
<script type="text/javascript" src="../static/js/crypto-js.min.js" charset="utf-8"></script>
<script>
var form = '{{ form }}';
var encryptedMsg = '{{ ciphertext }}';
if (sessionStorage.getItem("password")) {
var passphrase = sessionStorage.getItem("password");
var plainHTML = CryptoJS.AES.decrypt(encryptedMsg, passphrase).toString(CryptoJS.enc.Utf8);
document.write(plainHTML);
document.close();
} else {
var plainHTML = CryptoJS.enc.Base64.parse(form).toString(CryptoJS.enc.Utf8);
document.write(plainHTML);
document.close();
}
document.getElementById('staticrypt-form').addEventListener('submit', function(e) {
e.preventDefault();
var passphrase = document.getElementById('staticrypt-password').value;
try{
var plainHTML = CryptoJS.AES.decrypt(encryptedMsg, passphrase).toString(CryptoJS.enc.Utf8);
}
catch(err) {
document.getElementById("error").innerHTML = "Wrong keyword entry.";
return;
}
document.write(plainHTML);
document.close();
});
</script>
</body>
</html>