Method for transmitting a boot code, with improved data security, from a programming device to a microcontroller, having the steps of: a) creating, by means of the programming device, a first public key, a first private key and a password; b) generating, by means of the programming device, a bootloader binary for execution on the microcontroller, the bootloader binary comprising at least: - a bootstrap loader for execution on the microcontroller, - the password, - the first public key encrypted by means of the password, - a set of bootloader routines encrypted by means of the password for execution on the microcontroller, the set of encrypted bootloader routines comprising: a generation routine for generating a second public key and a second private key, and a decryption routine for decrypting the first public key; and - a decryption routine, for execution on the microcontroller, for decrypting the bootloader routines encrypted by means of the password; c) estimating, by means of the programming device, a tolerable total processing time, which consists of the processing times of steps d) to f); d) transmitting the bootloader binary from the programming device to the microcontroller; e) executing, by means of the microcontroller, the bootstrap loader code, the decryption routine for decrypting the bootloader routines encrypted by means of the password, and the decrypted bootloader routines; f) transmitting at least the second public key from the microcontroller to the programming device; g) if the actual processing times of steps d) to f) are outside the tolerable total processing time, terminating the method; and h) if the actual processing times of steps d) to f) are within the tolerable total processing time, encrypting, by means of the programming device, the boot code by means of the second public key and transmitting an encrypted boot code from the programming device to the microcontroller. a) creating, by means of the programming device, a first public key, a first private key and a password; b) generating, by means of the programming device, a bootloader binary for execution on the microcontroller, the bootloader binary comprising at least: - a bootstrap loader for execution on the microcontroller, - the password, - the first public key encrypted by means of the password, - a set of bootloader routines encrypted by means of the password for execution on the microcontroller, the set of encrypted bootloader routines comprising: a generation routine for generating a second public key and a second private key, and a decryption routine for decrypting the first public key; and - a decryption routine, for execution on the microcontroller, for decrypting the bootloader routines encrypted by means of the password; - a bootstrap loader for execution on the microcontroller, - the password, - the first public key encrypted by means of the password, - a set of bootloader routines encrypted by means of the password for execution on the microcontroller, the set of encrypted bootloader routines comprising: a generation routine for generating a second public key and a second private key, and a decryption routine for decrypting the first public key; and a generation routine for generating a second public key and a second private key, and a decryption routine for decrypting the first public key; and - a decryption routine, for execution on the microcontroller, for decrypting the bootloader routines encrypted by means of the password; c) estimating, by means of the programming device, a tolerable total processing time, which consists of the processing times of steps d) to f); d) transmitting the bootloader binary from the programming device to the microcontroller; e) executing, by means of the microcontroller, the bootstrap loader code, the decryption routine for decrypting the bootloader routines encrypted by means of the password, and the decrypted bootloader routines; the bootstrap loader code, the decryption routine for decrypting the bootloader routines encrypted by means of the password, and the decrypted bootloader routines; f) transmitting at least the second public key from the microcontroller to the programming device; g) if the actual processing times of steps d) to f) are outside the tolerable total processing time, terminating the method; and h) if the actual processing times of steps d) to f) are within the tolerable total processing time,