Home > Web Front-end > JS Tutorial > js implements hexadecimal encoding of strings without encryption_javascript skills

js implements hexadecimal encoding of strings without encryption_javascript skills

WBOY
Release: 2016-05-16 16:51:17
Original
1353 people have browsed it

Today I saw someone in the group asking a question about hexadecimal encoding, so I wrote a small program using JS to convert it. Remember: this is just encoding, not encryption!

Convert string to hexadecimal encoding:

Copy code The code is as follows:

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"));

Hexadecimal encoding to string:
Copy code The code is as follows:

str="x68x74x74x70x3ax2fx2fx77x77x77x2ex71x71x2ex63x6fx6d";
//Paste this string into the Chrome browser or FireBug console and press Enter to see the original string content.
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 admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template