jlinoff / lock_files Goto Github PK
View Code? Open in Web Editor NEWPython command line tool to encrypt or decrypt multiple files at a time using AES encryption and a common password.
License: MIT License
Python command line tool to encrypt or decrypt multiple files at a time using AES encryption and a common password.
License: MIT License
Will there be a problem with this?
I mainly think about encrypting large files. I think scripts should have this function, which is perfect.
bufferSize = 64 * 1024000
def read_file(opts, path, stats):
'''
Read the file contents.
'''
try:
while True:
with open(path, 'rb') as ifp:
data = ifp.read(bufferSize)
stat_inc(stats, 'read', len(data))
return data
except IOError as exc:
get_err_fct(opts)('failed to read file "{}": {}'.format(path, exc))
return None
My file is too large, more than 10G, and our memory is not so big, it can not read such a large file at one time, hope add the function of large file encryption.
It was pointed out to me today that writing files in place was dangerous because data would be lost if the disk fills up during a write operation. This needs to be changed.
Many thanks to Mick for pointing this out.
Hello, I installed this repo and I was checking it out to use it within a project. However, it turns out after I encrypt something and the time for decryption comes, the decryption never fails. No matter what password you choose it always decrypts. Please try this out and inform me if I might be doing something wrong or if your code needs editing.
the file size is 5.16GB,VERSION = '1.1.3'
C:\Users\vinso\Desktop\lock_files>lock_files.py -P vinson -vv --lock D:\360Downloads\Software
INFO:544 lock "D:\360Downloads\Software\vinson.vhdx" --> "D:\360Downloads\Software\vinson.vhdx.locked"
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Python27\lib\threading.py", line 801, in __bootstrap_inner
self.run()
File "C:\Python27\lib\threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "C:\Users\vinso\Desktop\lock_files\lock_files.py", line 455, in thread_process_file
process_file(opts, password, entry, stats)
File "C:\Users\vinso\Desktop\lock_files\lock_files.py", line 588, in process_file
lock_file(opts, password, path, stats)
File "C:\Users\vinso\Desktop\lock_files\lock_files.py", line 548, in lock_file
data = AESCipher(openssl=opts.openssl).encrypt(password, content)
File "C:\Users\vinso\Desktop\lock_files\lock_files.py", line 187, in encrypt
ciphertext_binary = encryptor.update(padded_plaintext) + encryptor.finalize()
File "C:\Python27\lib\site-packages\cryptography\hazmat\primitives\ciphers\base.py", line 149, in update
return self._ctx.update(data)
File "C:\Python27\lib\site-packages\cryptography\hazmat\backends\openssl\ciphers.py", line 124, in update
n = self.update_into(data, buf)
File "C:\Python27\lib\site-packages\cryptography\hazmat\backends\openssl\ciphers.py", line 140, in update_into
self._backend._ffi.from_buffer(data), len(data)
OverflowError: integer 5540675600 does not fit '32-bit int'
A number of folks have pointed this out to me privately and they are correct. The pycrypto package is old. I am working on replacing it with the cryptography package now.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.