The invention discloses a dynamic code anti-counterfeiting method and a system, and the dynamic code anti-counterfeiting method is characterized by attaching a dynamic code anti-counterfeiting recognizer and a password lock on a commodity, leading each dynamic code anti-counterfeiting recognizer to have a unique machine code, leading the dynamic code anti-counterfeiting recognizer to generate cryptograph of an anti-counterfeiting code through an encryption formula based on the machine code, time and a key, leading a consumer to obtain the cryptograph through the recognizer, submitting the cryptograph to a server by using the telephone, the short message or the network way, leading the server to carry out decryption according to the cryptograph, the time of the server and the key, obtaining the machine code, further being in contrast with the machine code stored in a database, feeding back the authenticity and a password to the consumer, and leading the consumer to open the password lock attached on the commodity through the password, wherein the machine code which is inquired once can not be re-inquired. The system has simple structure, few elements, low production cost and good anti-counterfeiting effect, and can replace a traditional anti-counterfeiting label for use.