JS Binary Conversion

Source: Internet
Author: User

JS's binary conversion, divided into 2 binary, 8 binary, 10 binary, 16 binary between the mutual conversion, we directly use the object. ToString () can be implemented:

Run the following code

10 binary to 16 binary. ToString (+)//= "A"//8 into 16 binary (012). ToString (+)//= "A"//16 into 10 binary (0x16). ToString (10)/ /= "22"//16 into 8 binary (0x16). ToString (8)//= "26"//10 into 2//=> (1111). ToString (2)//= "10001010111"// 8 binary to 2 binary//=> (01111). ToString (2)//=> "1001001001"//16 into 2//=> (0x16). ToString (2)//= "10110"

If you want to handle 2 binary to 10, 16 to 10, 8 to 10, you need to use the Paresint method:

Run the following code

2 binary to 10 binary, parseint (10,2)//=>2//2 to 10, parseint (100,2)//=>4//16 to 10 binary parseint (+)//=>18// 8 binary to 10 binary parseint (12,8); =>10

Binary conversion

If you want to achieve the conversion between the system, you can use the Parseint method, first converted to 10, and then the use of ToString (parameters), transformed into different systems;

The ToString and Parseint methods enable you to implement a binary 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 decryption

Convert the string to Unicode, and then convert the Unicode to a different binary, implementing Code encryption Processing:

Run the following code

<! DOCTYPE html>

  0 wide characters

Using the 0 width of the 0 wide character, we convert all the strings into binary, then use the 0 wide character to represent, then the resulting string length will be 0, the main anti-compilation can be restored,

Run the following code

<! DOCTYPE html>

JS binary conversion

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.