学做视频t的网站,榆林网站建设熊掌号,购物网站项目简介,南昌官网seo诊断js 摘要算法 base64加密解密 unescape()和escape()对字符串进行编码 encodeURI()和decodeURI()编码 encodeURIComponent()和decodeURIComponent()编码base64#xff1a;双向加密方式。1.GitHub中下载base64https://github.com/dankogai/js-base642.对应的HTML中调用//加密var …js 摘要算法 base64加密解密 unescape()和escape()对字符串进行编码 encodeURI()和decodeURI()编码 encodeURIComponent()和decodeURIComponent()编码base64双向加密方式。1.GitHub中下载base64https://github.com/dankogai/js-base642.对应的HTML中调用//加密var encodeStr Base64.encode(abcd1234);console.log(encodeStr);//解密var decodeStr Base64.decode(encodeStr);console.log(decodeStr);3.显示结果YWJjZDEyMzQabcd12344.对于数据加密来讲,base64只是达到了让人看到数据,不知道数据的内容,而无法做到真正的安全,所以base64另外一个用途是用来进行数据的传输.md5摘要算法它是单向的。1.原理MD5是一个安全的散列算法有两个特点1、输入两个不同的字符串不会得到相同的输出值 。2、无法从算法入手还原出MD5算法处理前的结果即过程不可逆。2.实用demo$(#btn).click(function () {var password $(#pwd).val();var passwd md5(password);console.log(, password)console.log($$$$$, passwd)})unescape()和escape()对字符串进行编码escape() 函数可对字符串进行编码这样就可以在所有的计算机上读取该字符串。1.语法escape(string)返回值已编码的 string 的副本。其中某些字符被替换成了十六进制的转义序列。2.实例document.write(escape(Visit W3School!) )document.write(escape(?!()#%))输出Visit%20W3School%21%3F%21%3D%28%29%23%25%263.说明该方法不会对 ASCII 字母和数字进行编码也不会对下面这些 ASCII 标点符号进行编码 * - _ . / 。其他所有的字符 都会被转义序列替换。4.提示提示可以使用 unescape() 对 escape() 编码的字符串进行解码。decodeURI() 和 decodeURIComponent()1.定义encodeURI() 函数可把字符串作为 URI 进行编码。2.语法encodeURI(_URIstring_)3.说明该方法不会对 ASCII 字母和数字进行编码也不会对这些 ASCII 标点符号进行编码 - _ . ! ~ * ( ) 。该方法的目的是对 URI 进行完整的编码因此对以下在 URI 中具有特殊含义的 ASCII 标点符号encodeURI() 函数是不会进行转义的;/?:$,#如果 URI 组件中含有分隔符比如 ? 和 #则应当使用 encodeURIComponent() 方法分别对各组件进行编码。4.实例document.write(encodeURI(http://www.w3school.com.cn)\ )document.write(encodeURI(http://www.w3school.com.cn/My first/))document.write(encodeURI(,/?:$#))输出http://www.w3school.com.cnhttp://www.w3school.com.cn/My%20first/,/?:$#encodeURIComponent()和decodeURIComponent()编码1.定义encodeURIComponent() 函数可把字符串作为 URI 组件进行编码。2.语法encodeURIComponent(URIstring)3.说明该方法不会对 ASCII 字母和数字进行编码也不会对这些 ASCII 标点符号进行编码 - _ . ! ~ * ( ) 。其他字符(比如 ;/?:$,# 这些用于分隔 URI 组件的标点符号)都是由一个或多个十六进制的转义序列替换的。请注意 encodeURIComponent() 函数 与 encodeURI() 函数的区别之处前者假定它的参数是 URI 的一部分(比如协议、主机名、路径或查询字符串)。因此 encodeURIComponent() 函数将转义用于分隔 URI 各个部分的标点符号。4.实例document.write(encodeURIComponent(http://www.w3school.com.cn))document.write()document.write(encodeURIComponent(http://www.w3school.com.cn/p 1/))document.write()document.write(encodeURIComponent(,/?:$#))输出http%3A%2F%2Fwww.w3school.com.cnhttp%3A%2F%2Fwww.w3school.com.cn%2Fp%201%2F%2C%2F%3F%3A%40%26%3D%2B%24%23