How to make an encrypted folder?

How to make an encrypted folder ?
What I want: The Folder contains a file. When you just look at it, for example a cat ~/myfle.txt, you can see garbage.
And if you entered the password, you can mount it as a folder with normal contents.
Please advise (looking for cli, not gui)

First, I don’t know.

I’ve seen “LUKS” mentioned as in how to install with encrypted filesystem. Filesystems are definitely mounted as directories.
The initrd and ISO-files are, well, files that are mounted as filesystems into some directories.
It should be possible to combine those two ideas and have a file that has encrypted filesystem, and then mount it.

Alas, then you can’t see the contents of the folder before mount, and once you see you can read the files too.

Package ansible-core has command ansible-vault that can encrypt and access files. Perhaps that would be closer to what you seek?

You can use ecryptfs if you want to encrypt a directory and all sub-folders and files contained within it for example.