Skip to content

SnowmanPrograms/FlashLock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FlashLock - 极速原地视频加密工具 / Ultra-fast In-place Video Encryption Tool

English | 中文


English

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.

🚀 Core Features

  • 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 Rayon for 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+C to stop processing safely without corrupting the current file.
  • Windows Friendly: Automatically keeps the console window open after completion when run via double-click.

🛠️ Installation

Ensure you have the Rust toolchain installed.

git clone https://github.com/your-repo/FlashLock.git
cd FlashLock
cargo build --release

The binary will be available at target/release/FlashLock.exe.

📖 Usage

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:

  1. Scan the directory and show a summary of files found.
  2. If both plain and .locked files are present, it offers a menu to process all, only encrypt, or only decrypt.
  3. Ask for confirmation before modifying any files.
  4. 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

⚠️ Risk Warning

  • 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 会:

  1. 扫描目录并显示发现的文件统计。
  2. 如果同时存在普通视频和 .locked 文件,会提供菜单让您选择全部处理、仅加密或仅解密。
  3. 在执行任何修改前请求确认。
  4. 执行完毕后等待回车退出(方便双击运行的用户查看结果)。

使用示例:

# 对当前目录下的视频进行加/解密
FlashLock.exe

# 使用自定义密码和 8MB 头部大小处理指定目录
FlashLock.exe -p my_secret_key -s 8 ./my_videos

# 运行预览模式
FlashLock.exe --dry-run

⚠️ 风险提示

  • 数据损坏风险:由于采用原地写入,如果在写入文件头的几毫秒内发生断电或系统崩溃,可能导致该文件头部损坏。建议在稳定的系统环境下使用。
  • 安全性说明:此工具主要用于“防君子不防小人”(防止直接播放和预览)。由于视频主体大部分未加密,专业取证工具仍可能恢复部分视频流。

About

快速加密当前文件夹下文件头部。目前支持视频文件。

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages