(JS implementation) the script for encrypting and decrypting coordinates in MapBar

Source: Internet
Author: User

A friend asked me this question. I found it and sent it today. I don't know if it is correct.
However, I personally think Mapbar is worth learning. At least I won't give you the coordinates of the codes.
I don't know if my Mapbar friends will tell me if they want to tell me. Well, it doesn't matter. I recently want to write an article to give you some personal suggestions. I think it's okay to say something bad. After a while, write it.

The following is the JavaScript code for encryption and decryption in the Mapbar. I made a simple description of what is in hexadecimal notation and hexadecimal notation. I also feel dizzy.
The result of the instance is as follows:
Value of sdsbwvjabfa after decryption: 121.46979, 31.23245
31.23245, 121.46979 encrypted value: IJSDSBZVJABFA
Of course, you can also use other coordinates for testing and testing.
Friendly reminder: the constant value in Mapbar may have changed. The value obtained by the current method is different from that obtained by Baidu.
The following code is copied and saved as a webpage.

Encryption and decryption in Mapbar (JS)
Copy codeThe Code is as follows:
<Script language = "javascript">
// A constant, but the value of encryption and decryption changes.
Var strLicenseKey = 699;
// Decrypt coordinates
Function jiemi (meT ){
Var W7pj =-1;
Var I524S = 0;
Var qk_X = '';
For (var I = 0; I <meT. length; I ++) {var j86T = parseInt (meT. charAt (I), 36)-10;
If (j86T> = 10) j86T = j86T-7; qk_X + = (j86T). toString (36 );
If (j86T> I524S) {W7pj = I; I524S = j86T} var U8T = parseInt (qk_X.substring (0, W7pj), 16 );
Var f9v8D = parseInt (qk_X.substring (W7pj + 1), 16 );
Var H1433 = new Array ();
H1433 [0] = (U8T + f9v8D-parseInt (strLicenseKey)/2;
H1433 [1] = (f9v8D-H1433 [0])/100000.0;
H1433 [0]/= 100000.0;
Return H1433 };
// Decrypted coordinate instance
Document. write ('This is the decrypted value of IJSDSBWVJABFA: <br>' + jiemi ('ijsdsbwvjabfa ') +' <br> ');
// Encrypt coordinates
Function jiami (e53, b92 _)
{
Var WVd94 = parseInt (parseFloat (e53) * 100000 );
Var j7_2 = parseInt (parseFloat (B92 _) * 100000 );
Var rpB = (j7_2-WVd94 + parseInt (strLicenseKey). toString (16 );
Var ie9 = (j7_2 + WVd94). toString (16 );
Var H1433 = '';
For (var I = 0; I <rpB. length; I ++)
{
Var k6A36 = parseInt (rpB. charAt (I), 16 );
H1433 + = (k6A36> = 10 )? (K6A36 + 7): k6A36) + 10). toString (36)
}
H1433 + = 'Z ';
For (var I = 0; I <ie9.length; I ++)
{
Var k6A36 = parseInt (ie9.charAt (I), 16 );
H1433 + = (k6A36> = 10 )? (K6A36 + 7): k6A36) + 10). toString (36)
}
Return H1433.toUpperCase ()
}
// Encrypt the instance
Document. write ('this is the 31.23245, 121.46979 encrypted value: <br> '+ jiami ('31. 100', '192. 100 '));
</Script>

Related Article

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.