JS hexadecimal conversion and its functions; JS hexadecimal conversion
Js hexadecimal conversion is divided into two hexadecimal, octal, 10-hexadecimal, and hexadecimal conversion. We can directly use the object. toString () to achieve this:
Run the following code:
// Convert the hexadecimal value to the hexadecimal value (10 ). toString (16) // => "a" // convert the hexadecimal value to the hexadecimal value (012 ). toString (16) // => "a" // convert the hexadecimal value to the hexadecimal value (0x16 ). toString (10) // => "22" // convert the hexadecimal value to the hexadecimal value (0x16 ). toString (8) // => "26" // convert the hexadecimal value to a binary value. // => (1111 ). toString (2) // => "10001010111" // convert the hexadecimal value to a binary value. // => (01111 ). toString (2) // => "1001001001" // convert hexadecimal format to binary format // => (0x16 ). toString (2) // => 10110"
If you want to process binary to decimal, hexadecimal to decimal, and hexadecimal to decimal, you need to use the paresInt method:
Run the following code:
// 2 to 10; parseInt () // => 2/2 to 10; parseInt) // => 4 // hexadecimal to 10 hexadecimal parseInt (12, 16) // => 18 // octal to 10 hexadecimal parseInt (12, 8 ); // => 10
Hexadecimal conversion
If you want to convert between the current hexadecimal values, you can use the parseInt method to convert them to the 10th hexadecimal value first, and then use the toString (parameter) to convert them into different hexadecimal values;
The toString and parseInt methods can be used to implement a hexadecimal conversion tool:
Run the following code:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Simple encryption and decryption
Convert a string to unicode, and convert unicode to a different hexadecimal format to implement code encryption:
Run the following code:
<! DOCTYPE html>
Zero-width characters
With zero-width characters and zero-width characters, we convert all strings into binary values, and then use zero-width characters for representation. Then, the length of the generated string is 0, which can be restored by decompiling,
Run the following code:
<! DOCTYPE html>
The above is a full description of the hexadecimal conversion and function in Javascript. I hope it will be helpful to you. If you want to learn more, please stay tuned to the help House website!