Those things that are linked to. NET

Source: Internet
Author: User
Tags base64



Order
This article was originally intended to write the latest technology, but in retrospect, the main work these days is with the PC-side of the link, has modified the bug in the project. Therefore, it is decided not to write the technical aspects of the first thing. Let's talk about the things I've been doing with. NET for a few days, and it's kind of interesting.

Background
Before the question is discussed, it is important to introduce the background clearly. PC-side login, authentication is the WebService of the server, of course, this is very common, the general also is to do so. As long as the PC is involved in reading data, writing data is required through the WebService server. And the PC side of the operation has a lot, also including the previous period of time to write the certificate, the PC needs to obtain a certificate is required to request the server. Therefore, after providing the interface to the PC, it is necessary for the service side to be connected with the PC side.

Body
The reason to write the link alone is because the interaction between Java and. NET is a bit of a problem in the process of linking, the initial problem makes people feel very involved, each has their own set of implementations, the docking does not seem easy. But then I found that, in fact, just find the right method, choose a unified standard, even if the implementation of their own different also have no relationship, so can "communicate."
Take the certificate, for a period of time just made a server to generate CA certificate function, and then this certificate is provided to the PC side, the PC side in the registered user request to generate a certificate, after success, will contain the certificate of the public key to the PC side to save. There are, of course, a number of authentication mechanisms that ensure that the PC-side accesses the real server. Then, the PC-side operation will be based on the certificate, by using the public key in the certificate, the public key encryption of the data, in the transmission process, even if the data is intercepted, no server issued a certificate private key is unable to unlock the data, which ensures the safe transmission of data.
The above is just a general process, the following is the question of where, this will involve the use of some cryptographic algorithms, of course, here does not discuss the algorithm. Just to say, the Java service side in the string encryption, found that the length of the encryption is limited, only the use of Shard encryption, which is mentioned in the front. Given the uniform standards, Java and. NET are partitioned together and decrypted instead of only one fragment.
Because in the transmission process, the use of BASE64 encoding, in the conversion encoding, the Java server to BASE64 encoded data to. NET (here is C #), C # using the same decoding method to get the data is garbled. This is the same result after many trials. Supposedly the standard is unified, although the implementation of the different ways, but in the interaction should be the same Ah, the same standard code, the adoption of the same standard should be decoded. Thought may be in the previous coding has a problem, so the previous code is unified for UTF-8, Hateful is, unexpectedly still garbled, this really does not make sense. After checking my code, I did not find any problems, and later through the data, I also learned that the BASE64 code between Java and. NET can be interoperable. So the question is definitely on the code.
Since I have also learned. NET, so I began to communicate with the PC-side personnel to understand his side of the implementation process, suddenly I noticed that he sent the data, did two times Base64 code, and I was in the service is just a decoding, then can imagine, the solution out of the data is certainly garbled ah. Through negotiation, the unified use of one-time encoding, one decoding. After testing again, there is no problem.

Conclusion
This is only one of the small problems, but also a more typical problem. Not only Java and. NET, the two languages in the interaction, we must choose a good standard, choose between the two languages common, in the interaction will not be any problem. Otherwise, the standard does not unify, realizes does not unify, then interacts with you to have the headache.


Those things that are linked to. NET

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.