I want to delete a file in a tarfile that is compressed. My project is in python 3 but i found a project called pyNMS for python 2 but i didn't get it to work even witha old version of python 2. My endgoal is to add extra information to a tar file that can be changed without rewrites of a 1GB or bigger tar file. The info file gets added after the file is written so it is at the end of the tar but the tar later gets password protected so i can't just remove everything after the filename with .split()
The tar command is not like zip.
There is no option for defining/using a password to protect the contents.
If the file is encrypted, that is a different tool, not tar.
You cannot manipulate the tar contents while encrypted. You must first decrypt, then perform any necessary operations using basic tar functionality.
So ... if your desire was to avoid manipulating GBs of data, limiting that to only MBs of data, via "injection" of a content delta, that is not possible.
NOTE: This next idea may not be within the scope of your problem, but it may provide the optimal solution.
If you created a partition dedicated to that content, then had that partition encrypted by default, you could then store your tar file in the clear, without encryption. This would allow you to perform all actions on the tar file directly, in the manner that you were hoping for, if the environment would allow you to cope with accessing an encrypted filesystem on the fly.
Also, if not a fully-dedicated partition, you could create an encrypted file which could act as a partition. This posting addresses that scenario.