A locking device for attachment to a box, the locking device comprising: an electronic timer, a code generation means for generating, using a current time value as provided by the electronic timer and a seed code related to a unique identifier of the box, a plurality of access codes in a first series and a second series, each access code in each series being valid for a predetermined period of time after which the subsequent code in that series becomes valid, a plurality of code input means for receiving an input code comprising a keypad, and a wireless communication means, wherein the wireless communication means corresponds to: a near-field communication means, a Bluetooth communication means or a wireless communication means according to the IEEE 802.11 standard, and a processor configured to: receive and store the currently valid access codes in the first and second series from the code generation means; receive input codes input by via the code input means, determine, from a time at which an input code that corresponds to a currently valid access code is input, an elapsed fraction of the validity period of the currently valid access code, and unlock the lock in response to input of a code that corresponds to a currently valid access code, wherein the period of validity of each access code in the first series partially overlaps the period of validity of two adjacent access codes in the second series, and wherein the processor is further configured to adjust the time registered in the electronic timer on the basis of the elapsed fraction of the validity period of the currently valid access code and also on the basis of which of the keypad and the wireless communication means is used to input the code. an electronic timer, a code generation means for generating, using a current time value as provided by the electronic timer and a seed code related to a unique identifier of the box, a plurality of access codes in a first series and a second series, each access code in each series being valid for a predetermined period of time after which the subsequent code in that series becomes valid, a plurality of code input means for receiving an input code comprising a keypad, and a wireless communication means, wherein the wireless communication means corresponds to: a near-field communication means, a Bluetooth communication means or a wireless communication means according to the IEEE 802.11 standard, and a near-field communication means, a Bluetooth communication means or a wireless communication means according to the IEEE 802.11 standard, and a processor configured to: receive and store the currently valid access codes in the first and second series from the code generation means; receive input codes input by via the code input means, determine, from a time at which an input code that corresponds to a currently valid access code is input, an elapsed fraction of the validity period of the currently valid access code, and unlock the lock in response to input of a code that corresponds to a currently valid access code, wherein receive and store the currently valid access codes in the first and second series from the code generation means; receive input codes input by via the code input means, determine, from a time at which an input code that corresponds to a currently valid access code is input, an elapsed fraction of the validity period of the currently valid access code, and unlock the lock in response to input of a code that corresponds to a currently valid access code, wherein determine, from a time at which an input code that corresponds to a currently valid access code is input, an elapsed fraction of the validity period of the currently valid access code, and unlock the lock in response to input of a code that corresponds to a currently valid access code, wherein the period of validity of each access code in the first series partially overlaps the period of validity of two adjacent access codes in the second series, and wherein the processor is further configured to adjust the time registered in the electronic timer on the basis of the elapsed fraction of the validity period of the currently valid access code and also on the basis of which of the keypad and the wireless communication means is used to input the code.