To encrypt a file test.txt, you can use the following command:
This creates an encrypted file test.txt.encrypted. Recall that encryption is based on the public key of the intended recipient. As a result, GPG will ask you about the user ID of the intended recipient. If the file is not to be sent to anyone, you still need to use your own user ID as the recipient.
This command takes the original file test.txt and creates the encrypted version test.txt.encrypted.
If you do not want GPG to ask you interactively about the recipient, you can use the -r option: