FlashLock is a high-performance, lightweight CLI tool written in Rust, designed to solve the issues of long processing times and double disk space usage when dealing with large video files.
By employing an In-place Header Encryption strategy, it only obfuscates the critical data area of the file and encodes the filename. It's built for extreme speed (milliseconds for GB-sized files) and zero disk space overhead.
- Extreme Speed: Only encrypts the critical header (e.g., 4MB), finishing almost instantly.
- Zero Space Increment: Performs I/O operations directly on the original file. No temporary files, no extra space needed.
- Filename Obfuscation: Encodes filenames (Base64) to protect privacy from a quick glance. Supports long filename fallback (no obfuscation if name > 255 chars).
- Safety First:
- CRC32 Verification: Calculates CRC32 of the original header before encryption. Decryption will refuse to write to disk if the password or data is incorrect.
- Atomic-like Metadata: Writes a 32-byte footer at the end of the file to identify FlashLock-encrypted files (Magic:
FLASHLOK).
- Parallel Execution: Utilizes
Rayonfor multi-threaded processing to maximize I/O throughput. - Interactive Confirmation: Scans and summarizes files (Plain vs Locked) before processing, with options to selectively encrypt or decrypt in mixed directories.
- Graceful Shutdown: Supports
Ctrl+Cto stop processing safely without corrupting the current file. - Windows Friendly: Automatically keeps the console window open after completion when run via double-click.
Ensure you have the Rust toolchain installed.
git clone https://github.com/your-repo/FlashLock.git
cd FlashLock
cargo build --releaseThe binary will be available at target/release/FlashLock.exe.
FlashLock.exe [OPTIONS] [PATH]Arguments:
[PATH]: The directory or file to process (defaults to current directory.).
Options:
-p, --password <PASSWORD>: Set a custom password for encryption (default:default_password).-s, --header-size <MB>: Size of the header to encrypt in MB (default:4).--dry-run: Scan and identify files without performing any encryption/decryption. Does not prompt for confirmation.-v, --verbose: Show detailed processing logs and file listings.-h, --help: Show help information.
Interactive Mode: When run without arguments (or in a folder), FlashLock will:
- Scan the directory and show a summary of files found.
- If both plain and
.lockedfiles are present, it offers a menu to process all, only encrypt, or only decrypt. - Ask for confirmation before modifying any files.
- Keep the window open at the end (for double-click users).
Examples:
# Encrypt/Decrypt videos in the current folder
FlashLock.exe
# Use a specific password and 8MB header size
FlashLock.exe -p my_secret_key -s 8 ./my_videos
# Dry run to see what would be processed
FlashLock.exe --dry-run- Data Corruption: Since it modifies files in-place, a power failure or crash during the few milliseconds of writing the header could corrupt the file. Use in a stable environment.
- Security Level: Designed for privacy protection against casual viewing. High-end forensic tools might still recover parts of the unencrypted video stream.
FlashLock 是一款基于 Rust 编写的高性能、轻量级命令行工具,专为解决大体积视频文件加密时耗时长、占用额外磁盘空间等痛点而设计。
本工具采用 “原地头部加密” 策略,仅对文件的关键数据区(头部)进行混淆,并对文件名进行编码。它不追求军用级安全性,而是专注于极致的处理速度(GB级文件毫秒级完成)和零磁盘空间占用。
- 极速处理:仅加密文件头部的关键字节(如 4MB),瞬间完成,无需全盘读写。
- 零空间增量:直接在原文件上进行 I/O 操作,无需产生临时文件,不占用额外空间。
- 文件名混淆:使用 Base64 编码文件名(可逆)。支持长文件名回退(超过 255 字符时仅添加后缀而不混淆)。
- 安全防呆:
- CRC32 校验:加密前记录原始头部校验值。解密时若密码错误或数据损坏,程序将拒绝写入磁盘,保护文件不被二次破坏。
- 元数据标识:在文件末尾追加 32 字节的 Footer,精准识别已加密文件 (Magic:
FLASHLOK)。
- 并发执行:利用
Rayon进行多线程并行处理,跑满磁盘 I/O。 - 交互确认:开始处理前会列出扫描统计(明文 vs 已加密),在混合目录下支持选择仅加密或仅解密。
- 优雅退出:支持
Ctrl+C信号,在收到中断请求时会安全完成当前文件的操作后再退出。 - 双击友好:在 Windows 下双击运行时,程序完成后会等待按键退出,不会直接闪退。
确保你已经安装了 Rust 开发环境。
git clone https://github.com/your-repo/FlashLock.git
cd FlashLock
cargo build --release编译生成的程序位于 target/release/FlashLock.exe。
FlashLock.exe [OPTIONS] [PATH]参数说明:
[PATH]: 要处理的文件夹或文件路径(默认为当前目录.)。
常用选项:
-p, --password <PASSWORD>: 设置加密密码(默认为default_password)。-s, --header-size <MB>: 设置加密头部的长度,单位 MB(默认为4)。--dry-run: 预览模式,仅扫描文件而不进行实际的加解密操作,不触发交互确认。-v, --verbose: 显示详细的处理进度日志和扫描列表。-h, --help: 显示帮助信息。
交互模式: 在直接运行或处理目录时,FlashLock 会:
- 扫描目录并显示发现的文件统计。
- 如果同时存在普通视频和
.locked文件,会提供菜单让您选择全部处理、仅加密或仅解密。 - 在执行任何修改前请求确认。
- 执行完毕后等待回车退出(方便双击运行的用户查看结果)。
使用示例:
# 对当前目录下的视频进行加/解密
FlashLock.exe
# 使用自定义密码和 8MB 头部大小处理指定目录
FlashLock.exe -p my_secret_key -s 8 ./my_videos
# 运行预览模式
FlashLock.exe --dry-run- 数据损坏风险:由于采用原地写入,如果在写入文件头的几毫秒内发生断电或系统崩溃,可能导致该文件头部损坏。建议在稳定的系统环境下使用。
- 安全性说明:此工具主要用于“防君子不防小人”(防止直接播放和预览)。由于视频主体大部分未加密,专业取证工具仍可能恢复部分视频流。