javascript 中的博主页面密码加密

blogger page password encryption in javascript

如何加密博客页面的密码保护?或者添加一个功能也许......所以它不会在代码中那么明显。

无论如何我可以添加一些 css 设计吗?或者让它在屏幕中央弹出。

<!-- paste this password form in your blogger post/page -->
<script language="JavaScript">
var password = ' '
password=prompt('This is password protected page, please enter password to continue.','');
if (password != 'password') {
location.href='https://errorpage.blogspot.com/404';
}
</script>
<!-- end password -->

ps : 我是 JavaScript 的新手,仍在学习中...

图片:https://i.imgur.com/oe2WiYc.png

这是表单的样子,但任何人都可以访问代码 (Ctrl + U) 并查看密码...

您可以通过css隐藏整个页面,然后使用js显示它。在 /head 之前输入下面的代码,看看 magic

<div style='position:fixed;overflow:none;height:100%;bottom:0;width:100%;top:0;display:table;text-align:center;background:hsla(0, 0%, 0%, 0.72)' id='passward-protected'>
<div style='display:table-cell;vertical-align:middle'>
This Page is password protected
<button onclick='enterpass()'>Enter Password</button>
</div>
</div>


<!-- paste this password form in your blogger post/page -->
<script language="JavaScript">
function enterpass(){
var password = ' '
password=prompt('This is password protected page, please enter password to continue.','');
if (password == 'password') {
document.getElementById('passward-protected').style.display='none';
}else{
alert('Wrong Password')
}
}
</script>