A locked door, chests, barrels and ender chest, with the locksmith workbench.
Put in a key or a lock and type a combination. The tooltip shows the combination it was given.
Sneak and use a padlock on a chest to lock it where it sits.