WEX5 real-combat encryption and decryption series (1) des algorithm introduction and invocation

Source: Internet
Author: User

As a web front-end application, communication with the server or back-end communication, as well as the transfer of data between different users, in some specific cases need to encrypt some information transmission, in an event to remove information and decryption, get the correct information. Looking at different languages and different algorithms, there are many options. Today, from the most basic encryption and decryption algorithm des speaking, in layman's terms, see how wex5 simple and efficient implementation des algorithm encryption and decryption. To facilitate the course needs, the production of demo, and JS modification notes.

One effect Demo

, encrypt, generate a bunch of garbled characters, decrypt and restore to get the correct information.

Two design ideas

Production and introduction of Des.js file, the front-end directly invoke the JS method to achieve encryption and decryption.

Three specific code and implementation

1 JS file production

Here to emphasize, des.js file, online a lot of is not a separate plug-in, some written in the HTML page, the JS fragment directly copied out, made JS file, for other pages to call. The specific algorithm logic does not have to tangle, to find its definition method can.

There is another problem: how to introduce an issue that does not standardize AMD files in Wex5. This is not the focus of today, interested in the officer net search.

The method provides two types of encryption and decryption, with 16 binary and non-16 binary differences as follows:

2 Introduction of JS

3 Invoking the JS method

JS file is the encryption and decryption method provided, there are two parameters, one is the key, and the other is the string to be processed. Here with Justep. The uuid.createuuid dynamically generates a key, with a key for each message.

(note) Yellow triangle exclamation mark hint method does not exist, in fact, is not, but the method is not on the same page, the measured result is the method has been correctly called.

Iv. Summary

1 JS file extraction and production, in fact, is to take some JS fragments out.

2 does not conform to the AMD specification of the JS file direct reference, call JS method can be.

WEX5 Real-combat encryption and decryption series (1) des algorithm introduction and invocation

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.