Data ciphering method based on NFC chip anti-fake certificate
Technical field
The present invention relates to a kind of data ciphering methods based on NFC chip anti-fake certificate.
Background technique
Traditional encryption is carried out data transmission with after reversible encryption method mostly, and no matter the data of reversible encryption are passing
In defeated mode, or in the method for encryption it is how complicated, but theoretically for be reversible encryption mode, encipherer after all
Data and code key can be subjected to a series of algorithm for encryption, be obtained used in ciphering process as long as decoding this in principle
Code key is just there is a high likelihood that decode ciphertext data, so existing in a possibility that probability theory decoding, and very high.But
It is if carrying out Data Encryption Transmission using irreversible encryption algorithm, ciphertext data can not be decoded by decoding this, but same
Encrypting this also can not be by ciphertext data convert at clear data, so data are passed when transmitting using irreversible encryption data
Defeated mode is worthless.
Summary of the invention
To overcome the shortcomings of existing technologies, the present invention provides a kind of data ciphering method based on NFC chip anti-fake certificate.
The technical scheme is that
A kind of data ciphering method based on NFC chip anti-fake certificate, comprising the following steps:
Step 1: user inputs correct user name and password by mobile terminal, and verifying logs in;
Step 2: after verifying user logins successfully, user name, password and timestamp being subjected to irreversible encryption and generate character
The code key of string format;
Step 3: business datum being spelled into upper timestamp and code key carries out Base64 Encryption Algorithm and carries out reversible encryption;
Step 4: and then by code key, encrypted business datum and system data, it can using the progress of Base64 Encryption Algorithm
Reverse encryption is encrypted to reversible ciphertext data A1;
Step 5: A1 being subjected to irreversible encryption using symmetric encipherment algorithm again, is encrypted to irreversible ciphertext data B1;
Step 6: reversible ciphertext data A1 and irreversible ciphertext data B1 are sent to server-side;
Step 7: after server-side receives ciphertext data A1 and ciphertext data B1;
Step 8: first reversible ciphertext data A1 being decrypted according to code key with Base64 reversible encryption method;
Step 9: the clear data A2 after being decrypted;
Step 10: wherein clear data A2 includes that mobile terminal is transmitted through the system data come and encrypted business datum;Again
It will obtain encrypted business datum to be decrypted with Base64 reversible encryption method, and obtain being transmitted through the industry come when the request of mobile terminal
Business parameter;
Step 11: irreversible encryption method is carried out with symmetric encipherment algorithm again, and clear data A2 is subjected to irreversible encryption,
Obtain encrypted irreversible ciphertext data B2;
Step 12: and then judge whether ciphertext data B2 and ciphertext data B1 are identical;
Step 13: if identical, then it represents that data are not maliciously tampered during transmission, and data are effective;If
It is not identical, indicate that data are kidnapped and distorted by third party in transmission process, data invalid
Step 15: process execution terminates.
The system data includes timestamp sysTimetamp, mobile end equipment unique identifier deviceId, is used for
Distinguish the identifier that the side for sending and requesting is the APP mobile phone either deviceType of dedicated writer, user's logging state
The unique identification loginid of token and login user.
The business datum is data when mobile terminal is requested or when server-side return, including NFC label is uniquely marked
Know batch unique identification Batchid, NFC of symbol UID, commodity unique identifier GSC, enterprise unique identifier Entid, commodity
Tag state WriteStatus, production time Productiondate, validity period Expirydate.
The code key is to carry out the token generated after irreversible encryption operation according to timestamp after user logins successfully.
The invention has the advantages that
It prevents interaction data between the mobile terminal APP (NFC mobile phone) and server-side (cloud server) to be maliciously tampered, intersects
" reversible encryption " and " irreversible encryption " algorithm is used, ensure that being perfectly safe for interaction data between mobile terminal and server-side.
Detailed description of the invention
Fig. 1 is flow diagram of the invention.
Specific embodiment
The invention will now be further described with reference to specific embodiments, the advantages and features of the present invention will be with description and
It is apparent.But examples are merely exemplary for these, and it is not intended to limit the scope of the present invention in any way.Those skilled in the art
Member it should be understood that without departing from the spirit and scope of the invention can details to technical solution of the present invention and form into
Row modifications or substitutions, but these modifications and replacement are fallen within the protection scope of the present invention.
The present invention relates to a kind of data ciphering methods based on NFC chip anti-fake certificate, the following steps are included:
Step 1: user inputs correct user name and password by mobile terminal, and verifying logs in;
Step 2: after verifying user logins successfully, user name, password and timestamp being subjected to irreversible encryption and generate character
The code key of string format;
Step 3: business datum being spelled into upper timestamp and code key carries out Base64 Encryption Algorithm and carries out reversible encryption;
Step 4: and then by code key, encrypted business datum and system data, it can using the progress of Base64 Encryption Algorithm
Reverse encryption is encrypted to reversible ciphertext data A1;
Step 5: A1 being subjected to irreversible encryption using symmetric encipherment algorithm again, is encrypted to irreversible ciphertext data B1;
Step 6: reversible ciphertext data A1 and irreversible ciphertext data B1 are sent to server-side.
Step 7: after server-side receives ciphertext data A1 and ciphertext data B1;
Step 8: first reversible ciphertext data A1 being decrypted according to code key with Base64 reversible encryption method;
Step 9: the clear data A2 after being decrypted;
Step 10: wherein clear data A2 includes that mobile terminal is transmitted through the system data come and encrypted business datum;Again
It will obtain encrypted business datum to be decrypted with Base64 reversible encryption method, and obtain being transmitted through the industry come when the request of mobile terminal
Business parameter;
Step 11: irreversible encryption method is carried out with symmetric encipherment algorithm again, and clear data A2 is subjected to irreversible encryption,
Obtain encrypted irreversible ciphertext data B2;
Step 12: and then judge whether ciphertext data B2 and ciphertext data B1 are identical;
Step 13: if identical, then it represents that data are not maliciously tampered during transmission, and data are effective;If
It is not identical, indicate that data are kidnapped and distorted by third party in transmission process, data invalid.
Step 15: process execution terminates.
The system data includes timestamp sysTimetamp, mobile end equipment unique identifier deviceId, is used for
Distinguish the identifier that the side for sending and requesting is the APP mobile phone either deviceType of dedicated writer, user's logging state
The unique identification loginid of token and login user.
The business datum is data when mobile terminal is requested or when server-side return, including NFC label is uniquely marked
Know batch unique identification Batchid, NFC of symbol UID, commodity unique identifier GSC, enterprise unique identifier Entid, commodity
The information such as tag state WriteStatus, production time Productiondate, validity period Expirydate.
The code key is to carry out the token generated after irreversible encryption operation according to timestamp after user logins successfully.