The invention relates to an
encryption method based on a
USB interface, which comprises the following steps of: electrifying equipment, electrifying a
USB encryption card, re-enumerating a
USB and waiting for an instruction; judging whether timing time is up or not; sending, by an upper computer, an SETUP token to the USB
encryption card; analyzing, by a USB
microcontroller, the token, and selecting, by the upper computer, data and an
algorithm for operation according to the wValue and wIndex which are randomly generated; judging whether the
instruction code is a control code or not, and if yes, sending the wValue and wIndex to a programmable device; transmitting, by the programmable device, an operation result to the USB
microcontroller; transmitting, by the programmable device, an operation result to the USB
microcontroller; and comparing, by the upper computer, the operation results, and if the comparison is correct, executing other logic functions. According to the method, a randomnumber is used for generating an encryption effect, the design is simple, a complex encryption
algorithm is not needed, but
cracking is difficult, and the effect of
software protection is effectivelyachieved.