To protect your personal data, it is best to lock your Mac when you’re not using it.
Enable the automatic locking of your Mac .
To activate the automatic locking of your Mac, go to your System Preferences and then in Security and privacy and click on General.
There, check the box Require password and choose after how long you want to lock your computer.
Now, to put the screen of your Mac in sleep mode, you can use the shortcut Control + Shift + Eject (or power button, depending on your model).
To reactivate your computer you simply have to press a key on your keyboard and enter your password.
Add a screen saver and a seating area are active.
To add a screen saver, go to your system Preferences, then click Desktop and screen saver and screen Saver.
There, click on active Corners, the bottom right. Choose the(s) corner(s) that you want to activate, and in the drop-down menu select Put the monitor in standby.
Now, every time that you place your mouse in the corner of the desktop that you have selected, your computer will be in sleep mode and you will have to enter your password to unlock it.
Lock your Mac in an instant.
To lock your Mac in an instant, use the shortcut :
Command + Alt + Eject (or power button).
Note that this will result in the shutdown of all the running tasks on your computer, even those in the background.