MD5 JavaScript 实现
我有一个表单,用户可以在输入文本字段
中插入密码。我想将该字符串转换为 md5,因此在发布到操作页面时,我将获得字符串的 md5 版本,而不是字符串。是否可以仅在帖子侧而不是输入文本中更改输入值?
像这样的东西:
function go(){
var pass = document.getElementsByName('pass')[0].value;
pass = md5(pass);
form.pass.value=pass;
}
只是一个伪代码。但这样它会改变用户在 md5 版本中插入的文本。我希望该用户不必看到它,但在 php 页面中,$_POST['pass'] 表单的操作将具有 md5 版本的 pass。我希望你明白。我的英语不是很好;)
解决方案: HTTPS 是最好的解决方案,但为了避免创建隐藏的输入字段,请使用 md5 密码填充它并清除密码字段;)
var rp = md5(pass.value);
document.rP.value=rp;
pass.value="";
i've a form in which user can inser a password in a input text field
. I want to convert that string in md5 so in post to the action page i will have the md5 version of string and not the string. is possible to change value of input only in post side and not in input text ?
Something like this:
function go(){
var pass = document.getElementsByName('pass')[0].value;
pass = md5(pass);
form.pass.value=pass;
}
is just a pseudocode. but in this way it will change the text insert by user in the md5 version. i want that user don't have to see it but in php page in action of form $_POST['pass'] will have md5 version of pass. i hope you understood. my english is not very good ;)
SOLUTION :
HTTPS is best solution, but to avoid it is possible to create an input field hidden, fill it with md5 pass and clean the password field ;)
var rp = md5(pass.value);
document.rP.value=rp;
pass.value="";
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你正试图以错误的方式解决这个问题。
最好的解决方案是使用 HTTPS。这意味着您不必担心输入的密码会被混淆。
在我的解决方案中,我通过 HTTPS 接受纯文本密码,然后进一步检查其密码是否是我本地存储的 12,000 个左右“简单”密码之一。
You are trying to go about this the wrong way.
The best solution is to use HTTPS. This means you don't have to worry about obfuscating the entered password.
In my solution I accept passwords in plain text over HTTPS and then go one step further by checking their password isn't one of 12,000 or so 'simple' passwords I have stored locally.