php – Codeigniter:如何在将表单提交给控制器之前加密密码?
我有一个简单的html登录表单
<form method="post" action="http://www.example.com/login"> <input type="text" name="text_box" /> <input type="password" name="pass_word" /> <input type="submit" name="submit"> </form> 当我提交表格并在控制器中 public function login(){ $pass_word = $this->input->post('pass_word'); die($pass_word); } 这里的问题,它显示了普通密码,如果我在控制器中键入123456,我得到123456. >这是安全问题吗? 怎么避免这个?在发送到控制器之前,我可以在视图中加密密码吗?请提前帮助,谢谢.
如果您的帖子数据(密码等)被截获,那么它只会以明文形式显示.使用SSL / HTTPS将为您发送的数据提供加密.我不会依赖客户端JavaScript或任何类似的用于验证/登录用户的目的.看到正在使用安全连接,它也可能给您的用户更多信心.
首先,我刚刚阅读了有关SSL和HTTPS的一般信息,以及SSL证书 – Wiki,Google和SO都是很好看的地方,那里有很多信息. 对于使用带有CI的SSL / HTTPS,我发现这些有用: > http://sajjadhossain.com/2008/10/27/ssl-https-urls-and-codeigniter/ 特别是强制ssl功能从Nigel’s post:
if (!function_exists('force_ssl')) { function force_ssl() { $CI =& get_instance(); $CI->config->config['base_url'] = str_replace('http://','https://',$CI->config->config['base_url']); if ($_SERVER['SERVER_PORT'] != 443) { redirect($CI->uri->uri_string()); } } } function remove_ssl() { $CI =& get_instance(); $CI->config->config['base_url'] = str_replace('https://','http://',$CI->config->config['base_url']); if ($_SERVER['SERVER_PORT'] != 80) { redirect($CI->uri->uri_string()); } }
这是一种编程方法,另一种方法是使用.htaccess(如果你使用的是Apache). (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |