什么是前端加密
前端加密就是在客户端对用户要提交的内容进行加密,从而降低服务器端的压力。
为什么要进行前端加密
进行前端加密值后,要对密码进行破译和破解,则需要在客户端方面消耗更多的资源,延长了破解时间,从而获得了更高的安全性。
前端加密方式:
在固定字符串上截取随机长度和打乱顺序的字符串
function randomString(length) { var chars = ‘0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz‘.split(‘‘); if (! length) { length = Math.floor(Math.random() * chars.length); } var str = ‘‘; for (var i = 0; i < length; i++) { str += chars[Math.floor(Math.random() * chars.length)]; } return str; }
RSA加密
MD5实现的前端加密
MD5 is a secure hash algorithm. It takes a string as input, and produces a 128-bit number, the hash. The same string always produces the same hash, but given a hash, it is not generally possible to determine the original string. Secure hash algorithms are useful for protecting passwords and ensuring data integrity.
原文:http://www.cnblogs.com/HXW-from-DJTU/p/6108611.html