How to encrypt/decrypt file or password in Linux?




  • Types of Encryption methods-
  1. GPG
  2. Ccrypt
  3. Bcrypt
  4. 7-zip
  •  Get all the require packages before you encrypt.
         
              $ sudo apt-get install gnupg bcrypt ccrypt p7zip-full
        
  1. GPG
  • To encrypt a single file
               $gpg -c filename 

             To encrypt data_info.txt file
   
             $gpg -c data_info.txt              //file will get saved as data_info.txt.gpg

              sample output
              Enter passphrase:   <your password>
              Repeat passphrase: <your password>

               //-c - Encrypt with symmetric cipher using a passphrase .
                         The default is CAST5.
  •      To decrypt file using gpg command-
               $gpg data_info.txt.gpg

                sample output:

               gpg data_info.txt.gpg
               gpg:CAST5 encrypt data
               Enter passphrase:  <your password>
  • To see list of the algorithms available-
              $gpg --version
           To use a different algorithm add for example: -crypto-algo
      
             $gpg -c -crypto-algo=3DES data_info.txt
  • Decrypt file and write output to file document.txt u can use-
             $gpg data_info.txt.gpg -o docement.txt
  
    2. Bcrypt
  • To encrypt with bcrypt use-
            $bcrypt data_info.txt     //file will b saved as data_info.txt.bfe
  • To decrypt the file use-
            $ bcrypt data_info.txt.bfe

    3. Ccrypt
  •  ccrypt command can be used in following ways:
  1. by using ccrypt directly with either the -e (to encrypt) or -d (to decrypt) options
  2. by using ccencrypt 
  •   To encrypt a file-
            $ ccencrypt data_info.txt   //original file is replaced by data_info.txt.cpt
  • To decrypt a file-
          $ ccdecrypt data_info.txt.cpt
    
      4. 7-Zip
  • The 7-zip compression tool also incorporates AES encryption. To create an encrypted archive use the "-p" parameter with 7z command
           $ 7z a -p data_info.txt.7z data_info.txt    //you will be asked to
                                                                           enter password, then the 
                                                                          file will be compressed 
                                                                           and encrypted.

Post a Comment

Previous Post Next Post