Encrypting archive and then dividing it into many parts

Unix & Linux Asked by user216488 on January 5, 2022

I have a personal archive of many files (more than 12Go)

I want to encrypt it with a password, then divide it into 100 parts.

How can I do so?

And how can I regroup it and de-encrypt it to get the files back?

2 Answers

If any of the 100 parts are lost/corrupted you could end up being unable to recover any files, I'd lean more towards 100 separate archives each encrypted.

But, with one giant split file you may end up needing 12Go (Gigabytes?) of free space to re-assemble the pieces, and another 12 to decrypt/view the archive, if your tools don't support pipeing with stdin/stdout.

Using tar & gpg & split together should work, like:

tar -c files | gpg -o- ... | split -b [size 1/100th of total] -

Options for split that might be useful may include:

  • -a3 generate suffixes of length N (default 2)
  • -d use numeric suffixes instead of alphabetic.
  • - read standard input.
  • outputfilename. name of output files

Answered by Xen2050 on January 5, 2022

To encrypt the file use openssl:

openssl aes-128-cbc -in the_archive -out the_archive.crypted

To split the file use split:

split -a 3 -b 100000 the_archived.crypted chunk.

To regroup the chunks use cat:

cat chunk.??? >the_archive.crypted

To decode the file use openssl again:

openssl aes-128-cbc -d -in the_archive.crypted -out the_archive

Answered by kmkaplan on January 5, 2022

Add your own answers!

Ask a Question

Get help from others!

© 2024 All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP