Your Question: How Do I Encrypt Text in Linux?

Your Question: How Do I Encrypt Text in Linux?
Contents

How do I encrypt a string in Linux?

  1. Generate a private/public key pair $ openssl genrsa -out rsa_key.pri 2048; openssl rsa -in rsa_key.pri -out rsa_key.pub -outform PEM -pubout.
  2. Encrypt the string using public key, and store in a file $ echo “stockexchange.com” | openssl rsautl -encrypt -inkey rsa_key.pub -pubin -out secret.dat.

How do I password protect a text file in Linux?

While editing a file, press Esc to ensure you’re in command mode and not insert mode. Type :X and press Enter. You’ll be prompted to enter a password, which the text file will be encrypted with. Type the password you want to use, press Enter, and type it again to confirm.

Marcus Vance
Author

Marcus Vance

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.