The embodiments of the present application provide a data protection method, electronic device, and storage medium, which relate to the field of
data security technology and can improve the security and privacy of data stored in a storage device shared by multiple users. The method includes: obtaining a root key through a first account and a first
password; creating an encrypted
home directory for the first account in the storage device, and setting the data in the encrypted
home directory to be encrypted and decrypted based on the root key; obtaining a second account and a second
password, and using the second account and the second
password as
authentication information for the encrypted
home directory of the first account when the storage device is mounted on the current electronic device; when a
user needs to access data in the encrypted home
directory of the first account, if the storage device is mounted on the current electronic device, accessing or modifying the data based on the first account and the first password, and the second account and the second password; if the storage device is mounted on another electronic device, accessing or modifying the data based on the first account and the first password.