A simple way to encrypt a file with a password is to use gpg (GnuPG). Suppose we have a file mysamplefile.txt, to encrypt it type the following on console.
$ gpg -c mysamplefile.txt
You will be asked to enter a paraphrase twice
A new file named mysamplefile.txt.gpg will be created.
To decrypt the file type
$ gpg mysamplefile.txt
Again it will ask the paraphrase and decrypt the file.