OpenSSL in Termux – Encryption and Security Tool

OpenSSL is a powerful command-line tool used for encryption, hashing, certificates, and secure connections. It provides many useful commands for working with files, passwords, keys, and SSL/TLS connections from the Termux terminal. OpenSSL is useful for beginners who want to learn basic encryption and security commands on Android.

Here’s what you can do with OpenSSL in Termux:

  • Create file hashes.
  • Encrypt and decrypt files.
  • Generate random data.
  • Create encryption keys.
  • Check SSL certificates.
  • Test HTTPS connections.
  • Encode and decode Base64 data.
  • Learn basic cryptography.

Install OpenSSL in Termux

Below are the simple commands to install OpenSSL in Termux. Copy and run each command one by one to install the tool.

Update Termux packages.

pkg update && pkg upgrade -y

Install OpenSSL.

pkg install openssl openssl-tool -y

Check the installed version.

openssl version

OpenSSL is now installed and ready to use.

Use OpenSSL in Termux

After installing OpenSSL, you can use different commands for hashing, encryption, certificates, random data, and secure connections.

Show the help menu.

openssl help

Generate random data.

openssl rand -hex 16

Generate a SHA-256 hash.

echo -n "Hello World" | openssl dgst -sha256

Generate a SHA-512 hash.

echo -n "Hello World" | openssl dgst -sha512

Calculate the SHA-256 hash of a file.

openssl dgst -sha256 filename.txt

Encode text with Base64.

echo -n "Hello World" | openssl base64

Decode Base64 text.

echo "SGVsbG8gV29ybGQ=" | openssl base64 -d

Encrypt a File

Create a test file.

echo "This is my secret file." > secret.txt

Encrypt the file with AES-256.

openssl enc -aes-256-cbc -salt -in secret.txt -out secret.txt.enc

Enter a password when OpenSSL asks for one. The encrypted file will be saved as secret.txt.enc.

Decrypt a File

Use the following command to decrypt the encrypted file.

openssl enc -d -aes-256-cbc -in secret.txt.enc -out decrypted.txt

Enter the same password that you used during encryption.

View the decrypted file.

cat decrypted.txt

Generate a 2048-bit RSA private key.

openssl genrsa -out private.key 2048

Generate a public key from the private key.

openssl rsa -in private.key -pubout -out public.key

Create a self-signed certificate.

openssl req -new -x509 -key private.key -out certificate.crt -days 365

View certificate information.

openssl x509 -in certificate.crt -text -noout

Check an HTTPS connection.

openssl s_client -connect example.com:443

You can use these commands to learn how OpenSSL works with files, hashes, encryption, keys, certificates, and secure connections in Termux.

End Note

OpenSSL is a useful tool for learning encryption and security in Termux. You can use simple commands to protect files, create hashes, generate keys, and check secure connections from your terminal.

SHARE THIS POST: