An image processing apparatus with which an external terminal can communicate, the apparatus comprising: accepting means for accepting a connection request from the external terminal; generation means for generating an identifier of a first number of digits that is assigned to the external terminal when an initial connection request is accepted by the accepting means; display means for displaying the identifier generated by the generation means; and control means, characterized in that the control means is configured to: when information corresponding to the identifier is accepted from the external terminal after the identifier is displayed by the display means, generate a public key and a private key and transmit the generated public key to the external terminal; when a second or subsequent connection request from the external terminal is accepted by the accepting means, generate a random value and transmit the generated random value to the external terminal after transmitting the public key to the external terminal; receive, from the external terminal, the transmitted random value and a common key to be used for an encrypted communication with the external terminal, the transmitted random value and the common key being encrypted by the transmitted public key; decrypt, with the generated private key, the received random value and common key which have been encrypted by the transmitted public key; compare the generated random value with the decrypted random value, and determine whether or not the generated random value and the decrypted random value match from the comparison result; and use the decrypted common key for the encrypted communication with the external terminal if it is determined that the generated random value and the decrypted random value match. accepting means for accepting a connection request from the external terminal; generation means for generating an identifier of a first number of digits that is assigned to the external terminal when an initial connection request is accepted by the accepting means; display means for displaying the identifier generated by the generation means; and control means, characterized in that the control means is configured to: when information corresponding to the identifier is accepted from the external terminal after the identifier is displayed by the display means, generate a public key and a private key and transmit the generated public key to the external terminal; when a second or subsequent connection request from the external terminal is accepted by the accepting means, generate a random value and transmit the generated random value to the external terminal after transmitting the public key to the external terminal; receive, from the external terminal, the transmitted random value and a common key to be used for an encrypted communication with the external terminal, the transmitted random value and the common key being encrypted by the transmitted public key; decrypt, with the generated private key, the received random value and common key which have been encrypted by the transmitted public key; compare the generated random value with the decrypted random value, and determine whether or not the generated random value and the decrypted random value match from the comparison result; and use the decrypted common key for the encrypted communication with the external terminal if it is determined that the generated random value and the decrypted random value match. when information corresponding to the identifier is accepted from the external terminal after the identifier is displayed by the display means, generate a public key and a private key and transmit the generated public key to the external terminal; when a second or subsequent connection request from the external terminal is accepted by the accepting means, generate a random value and transmit the generated random value to the external terminal after transmitting the public key to the external terminal; receive, from the external terminal, the transmitted random value and a common key to be used for an encrypted communication with the external terminal, the transmitted random value and the common key being encrypted by the transmitted public key; decrypt, with the generated private key, the received random value and common key which have been encrypted by the transmitted public key; compare the generated random value with the decrypted random value, and determine whether or not the generated random value and the decrypted random value match from the comparison result; and use the decrypted common key for the encrypted communication with the external terminal if it is determined that the generated random value and the decrypted random value match.