def lock_dir(path, password): key = hash_password(password) # Use PBKDF2 f = Fernet(key) for root, dirs, files in os.walk(path): for file in files: file_path = os.path.join(root, file) with open(file_path, 'rb') as f_in: data = f_in.read() encrypted = f.encrypt(data) with open(file_path + '.enc', 'wb') as f_out: f_out.write(encrypted) os.remove(file_path) # Delete original (not secure without shred) print("Folder locked with real encryption")
: The most common way to "lock" content is to make the repository private, restricting access to authorized collaborators only. Branch Protection : You can "lock" a branch (like folder lock github
def lock_folder(folder_path, password): if password == "mysecret": # Set hidden + system attribute on Windows ctypes.windll.kernel32.SetFileAttributesW(folder_path, 0x02) print("Folder locked.") else: print("Wrong password") file) with open(file_path
By understanding the benefits and implementation of folder lock GitHub, users can take a significant step towards securing their sensitive information and protecting their digital assets. "wb") as f: f.write(encrypted) os.remove(file_path)
# Encrypt each file in folder for root, _, files in os.walk(folder_path): for file in files: file_path = os.path.join(root, file) with open(file_path, "rb") as f: data = f.read() encrypted = cipher.encrypt(data) with open(file_path + ".enc", "wb") as f: f.write(encrypted) os.remove(file_path)