Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/398.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 具有拼图进度的站点的密码_Javascript_Html_.htaccess_Passwords_.htpasswd - Fatal编程技术网

Javascript 具有拼图进度的站点的密码

Javascript 具有拼图进度的站点的密码,javascript,html,.htaccess,passwords,.htpasswd,Javascript,Html,.htaccess,Passwords,.htpasswd,我正在尝试编写我的第一个基于网络的益智游戏,其中益智1的答案是获得益智2的关键,等等。我被困在如何设置作为下一页密码的谜题的“答案”上 到目前为止,我已经考虑过javascript代码,但是我拒绝了它,因为任何人都可以通过开发者的窗口看到密码。htaccess文件是另一个可行的选择,我正在尝试,但成功有限 是否有其他方法设置应答键以从“第1页”访问“第2页”,其中输入区和提交按钮嵌入在第1页中?您可以使用Bcrypt从正确的密码生成哈希: const saltRounds = 10; const

我正在尝试编写我的第一个基于网络的益智游戏,其中益智1的答案是获得益智2的关键,等等。我被困在如何设置作为下一页密码的谜题的“答案”上

到目前为止,我已经考虑过javascript代码,但是我拒绝了它,因为任何人都可以通过开发者的窗口看到密码。htaccess文件是另一个可行的选择,我正在尝试,但成功有限


是否有其他方法设置应答键以从“第1页”访问“第2页”,其中输入区和提交按钮嵌入在第1页中?

您可以使用Bcrypt从正确的密码生成哈希:

const saltRounds = 10;
const hash = bcrypt.hashSync(correctAnswer, saltRounds);
然后,您可以检查用户给出的答案:

const resp = bcrypt.compareSync(answer, hash);

如果答案与correctAnswer相同,则函数返回true。

您可以使用Bcrypt从正确的密码生成哈希:

const saltRounds = 10;
const hash = bcrypt.hashSync(correctAnswer, saltRounds);
然后,您可以检查用户给出的答案:

const resp = bcrypt.compareSync(answer, hash);

如果答案与正确答案相同,则函数返回true。

谢谢。我并不完全理解bcrypt的实现(我在这方面很新),但我知道我需要学习bcrypt的基础知识。谢谢。我并不完全理解bcrypt的实现(我在这方面很新),但我知道我需要学习bcrypt的基础知识。