A method of controlling access to an electronic device includes scanning a fingerprint of a user and obtaining a first image of the fingerprint. A preset number of feature points of the fingerprint from the first image are extracted. A distance value between each of the extracted feature points is adjusted to obtain a new image. A first slide path according to touch signals corresponding to the extracted feature points in the new image is identified. The first slide path is set as a password for unlocking the electronic device.