Package: czlib
CZLIBEncrypt and Compress all your files and write into another directory if there is updateClean the encrypted directory if files or directories have been deletedRestoreMinimize writing to SSDsUSAGEencrypt# User maintains two directories plain_dir and encrypted_dirimportczlibplain_dir="plain"encrypted_dir="encrypted"restored_dir="restored"key=czlib.make_key_from_passphrase(b"passphrase1234")# Delete all files, directories in encrypted_dir that don't exist in the plain_dirczlib.clean_encrypted_dir(plain_dir=plain_dir,encrypted_dir=encrypted_dir,)# read files in plain_dir, encrypt and write files into encrypted_dir if needed using 12 workersczlib.update_encrypted_dir(key=key,plain_dir=plain_dir,encrypted_dir=encrypted_dir,max_workers=12,)restoreimportczlibplain_dir="plain"encrypted_dir="encrypted"restored_dir="restored"key=czlib.make_key_from_passphrase(b"passphrase1234")# restore all files in encrypted_dir using 12 workersczlib.restore_encrypted_dir(key=key,encrypted_dir=encrypted_dir,restored_dir=restored_dir,max_workers=12,)certificateimportczlibcorrect_passphrase=b"passphrase123"cert=czlib.make_certificate(correct_passphrase)print("cert",cert)try:wrong_passphrase=b"passphrase456"_=czlib.verify_certificate(cert,wrong_passphrase)exceptAssertionErrorase:print("expected assertion error: ",e)key=czlib.verify_certificate(cert,correct_passphrase)print("generated key from correct passphrase",key)INSTALLATIONpipinstall--upgradeczlibDECRYPT IT YOURSELFSPECIFICATION 2.*You don't need to know the specification. For some folks who want to know exactly what happened with their files, here
is the specification forkey_fileand.gz.encfiles:three algorithms are used inczlib:SHA1,AES-256,DEFLATEencrypted files are updated only if either file is modified (mtime changes) or key is changedfile is decrypt-able ifsignaturematcheskey.gz.encfileheader:file_sig: little-endian encoded mtime of file in uint64key_sig:SHA1bytes of keyfile_size: little-endian encoded file size in uint64init_vec:AES256initialization vectorfile encrypted:AES256encryptedDEFLATEcompressed bytes with chunk size of2^27__________________________________________________________________________________
|                          header                           |   encrypted_data   |
|___________________________________________________________|____________________|
|   file_sig   |   key_sig   |   file_size   |   init_vec   |   encrypted_data   |
|   8 bytes    |   20 bytes  |   8 bytes     |   16 bytes   |   n bytes          |
|___________________________________________________________|____________________|SPECIFICATION 1.*You don't need to know the specification. For some folks who want to know exactly what happened with their files, here
is the specification forkey_fileand.enc1files:two algorithms are used inczlib:SHA1andAES-256inCBCmodeencrypted files are updated only if either file is modified (mtime changes) or key is changedfile is decrypt-able ifsignaturematcheskey.enc1fileheader:file_sig: little-endian encoded mtime of file in uint64key_sig:SHA1bytes of keyfile_size: little-endian encoded file size in uint64init_vec:AES256initialization vectorfile encrypted:AES256file encrypted bytes with chunk size of2^30__________________________________________________________________________________
|                          header                           |   encrypted_data   |
|___________________________________________________________|____________________|
|   file_sig   |   key_sig   |   file_size   |   init_vec   |   encrypted_data   |
|   8 bytes    |   20 bytes  |   8 bytes     |   16 bytes   |   n bytes          |
|___________________________________________________________|____________________|SPECIFICATION 0.*You don't need to know the specification. For some folks who want to know exactly what happened with their files, here
is the specification forkey_fileand.encfiles:ifkey_filedoes not exist,czlibwill create a random key of 32 bytes usingos.urandomencoded intohextwo algorithms are used inczlib:SHA1andAES-256inCBCmodeencrypted files are updated only if file_hash changesfile is decrypt-able ifsignaturematcheskey.encfilesignature:SHA1bytes of keyfile_hash:SHA1bytes of filefile_size: little-endian encoded file size in uint64iv:AES256initialization vectorfile encrypted:AES256file encrypted bytes with chunk size of2^30|   signature   |   file_hash   |   file_size   |   iv          |   encrypted_data  |
|   20 bytes    |   20 bytes    |   8 bytes     |   16 bytes    |   n bytes         |UPLOADrm-rfdistczlib.egg-info
pythonsetup.pysdist
twineuploaddist/*