Home > Web Front-end > JS Tutorial > body text

js实现字符串的16进制编码不加密_javascript技巧

php.cn
Release: 2016-05-16 16:51:17
Original
1206 people have browsed it

今天看到群里有人提问关于十六进制编码的问题,所以使用JS写了个小程序转换一下,记住:这只是编码,不是加密!

字符串转十六进制编码:

复制代码 代码如下:

str="http://www.qq.com";
len=str.length;
arr=[];
for(var i=0;iarr.push(str.charCodeAt(i).toString(16));
}
console.log("\\x"+arr.join("\\x"));

十六进制编码转字符串:
复制代码 代码如下:

str="\x68\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\x2e\x71\x71\x2e\x63\x6f\x6d";
//将此字符串粘贴到Chrome浏览器或者FireBug的控制台回车即可看到原本的字符串内容。
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Latest Issues
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!