A method for controlling an electronic device, the method comprising: receiving a command to upload an image to an external server; acquiring, based on the command, a first characteristic value corresponding to the image by inputting the image and a key of the electronic device into an encryption model trained to identify characteristic values based on an input image and an input key, wherein the first characteristic value is an image representation value extracted by passing the image and the key through a trained neural network as inputs; and transmitting the first characteristic value to the external server, wherein the key of the electronic device is one from among a password of the electronic device and identification information of the electronic device, wherein the method further comprising: receiving a retrieval command to retrieve an image related to a keyword; transmitting a request to the external server requesting a search related to the keyword; and receiving, based on the request, a second characteristic value corresponding to at least one search image related to the keyword from the external server, the at least one search image being at least one from among images classified based on a similarity comparison, restoring the at least one search image by inputting the second characteristic value corresponding to the at least one search image and the key of the electronic device into a decryption model trained to restore an image by using the second characteristic value corresponding to the at least one search image and the key as input data, wherein the encryption model and the decryption model are a neural network model comprising a plurality of network nodes configured to exchange data according to a convolution connection relationship. receiving a command to upload an image to an external server; acquiring, based on the command, a first characteristic value corresponding to the image by inputting the image and a key of the electronic device into an encryption model trained to identify characteristic values based on an input image and an input key, wherein the first characteristic value is an image representation value extracted by passing the image and the key through a trained neural network as inputs; and transmitting the first characteristic value to the external server, wherein the key of the electronic device is one from among a password of the electronic device and identification information of the electronic device, wherein the method further comprising: receiving a retrieval command to retrieve an image related to a keyword; transmitting a request to the external server requesting a search related to the keyword; and receiving, based on the request, a second characteristic value corresponding to at least one search image related to the keyword from the external server, the at least one search image being at least one from among images classified based on a similarity comparison, restoring the at least one search image by inputting the second characteristic value corresponding to the at least one search image and the key of the electronic device into a decryption model trained to restore an image by using the second characteristic value corresponding to the at least one search image and the key as input data, wherein the encryption model and the decryption model are a neural network model comprising a plurality of network nodes configured to exchange data according to a convolution connection relationship. receiving a retrieval command to retrieve an image related to a keyword; transmitting a request to the external server requesting a search related to the keyword; and receiving, based on the request, a second characteristic value corresponding to at least one search image related to the keyword from the external server, the at least one search image being at least one from among images classified based on a similarity comparison, restoring the at least one search image by inputting the second characteristic value corresponding to the at least one search image and the key of the electronic device into a decryption model trained to restore an image by using the second characteristic value corresponding to the at least one search image and the key as input data, wherein the encryption model and the decryption model are a neural network model comprising a plurality of network nodes configured to exchange data according to a convolution connection relationship.