我正在创建一个需要身份验证过程的 Web 应用程序。遗憾的是,我不能使用 HTTPS,所以我只能使用不安全的 HTTP。目前,我正在通过 HTTP 以纯文本形式发送密码……我知道这很糟糕(即使使用 HTTPS)!这就是为什么我搜索一种在 JS 中散列密码并将散列发送到服务器的原因。 你们知道我该怎么做吗? (根据我的需要,使用与 PHP 相同的河豚实现将是最佳解决方案)
谢谢!
编辑:我知道任何可以拦截字符串的人都可以连接,但他们不知道密码,只知道哈希值。
最佳答案
String.prototype.hashCode = function(){
var hash = 0;
if (this.length == 0) return hash;
for (i = 0; i < this.length; i++) {
char = this.charCodeAt(i);
hash = ((hash<<5)-hash)+char;
hash = hash & hash; // Convert to 32bit integer
}
return hash;
}
这是你可以用来在 JS 中散列密码的方法
礼貌:http://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/
关于javascript - JS中的哈希密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43892496/