Patent attributes
A method for realizing secure communication, comprises: Step 1, a card reader is powered on, determine a system working mode, perform an apple device verification and execute Step 2 if the system working mode is apple mode; execute Step 2 if the system working mode is USB mode; Step 2, wait for receiving an instruction, determine a first preset byte of the instruction, perform corresponding operation if the first preset byte is a first preset value; decrypt the instruction according to an initial encryption key, a key serial number and an algorithm corresponding to an algorithm flag, send the decrypted instruction to a card and execute Step 3 if the first preset byte is a second preset value; Step 3, when data returned by the card is received, the key serial number is updated, the algorithm according to the algorithm flag, the initial encryption key and the updated key serial number are configured to encrypt the data returned by the card, send the encrypted data to an upper computer via a corresponding interface according to the system working mode. According to the present invention, after a key agreement between the card reader and the upper computer, the key is updated, data is encrypted or decrypted by the updated key to improve safety of data communication.