Skip to content

Latest commit

ย 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

fhash

fhash

Hash your folder names with SHA-256, restore them anytime.
CLI ยท GUI ยท macOS Right-Click ยท Open Source

English | ไธญๆ–‡

macOS Windows MIT License Python Stars


โœจ What is fhash?

fhash replaces all subfolder names in a directory with short SHA-256 hashes (8 hex characters), while keeping a mapping file so you can restore the original names at any time.

Think of it as a reversible "anonymizer" for folder structures โ€” useful for privacy, testing, or sharing project layouts without revealing sensitive names.

Before & After

my_projects/                    my_projects/
โ”œโ”€โ”€ ๆˆ‘็š„้กน็›ฎ/          โ”€โ”€โ†’      โ”œโ”€โ”€ 9ce557b3/
โ”œโ”€โ”€ test_data/         โ”€โ”€โ†’      โ”œโ”€โ”€ e7d87b73/
โ”œโ”€โ”€ 2024ๅนดๆŠฅๅ‘Š/         โ”€โ”€โ†’      โ”œโ”€โ”€ 7c330497/
โ””โ”€โ”€ backend-api/       โ”€โ”€โ†’      โ””โ”€โ”€ d753230e/

Use Cases

Scenario How fhash helps
๐Ÿ”’ Privacy Obscure folder names before sharing or uploading
๐Ÿ“ฆ Anonymization Remove identifiable names from project structures
๐Ÿงช Testing Simulate opaque folder naming in CI/CD pipelines
๐ŸŽฏ Organization Temporarily hide project names while keeping structure intact
๐Ÿ“ธ Screenshots Hide sensitive folder names when taking screenshots

๐Ÿš€ Features

  • SHA-256 hashing โ€” 8-character hex hash per folder name (โ‰ˆ2.8 trillion combinations)
  • Fully reversible โ€” Restore original names from the mapping file at any time
  • Idempotent โ€” Running encode twice won't double-hash
  • Collision-safe โ€” Auto-extends hash length (8โ†’9โ†’10...) on collision
  • Dry-run preview โ€” See all changes before applying (--dry-run)
  • Hidden folder aware โ€” Skips . prefixed folders automatically
  • Unicode support โ€” Full CJK / emoji / Unicode folder name support
  • Auto backup โ€” Creates .bak before each operation
  • macOS Right-Click โ€” Native Finder Quick Actions (no third-party apps)
  • GUI App โ€” Cross-platform tkinter GUI, buildable as macOS .app and Windows .exe
  • Zero dependencies โ€” Pure Python stdlib (no pip install needed)

๐Ÿ“ฆ Installation

Option 1: Full Install (CLI + macOS Right-Click) โ€” Recommended for macOS

git clone https://github.com/zephyrq-z/fhash.git
cd fhash

# Install CLI to ~/bin/fhash
bash install.sh

# Install Finder right-click Quick Actions
bash install_quick_actions.sh

Option 2: CLI Only (macOS / Linux / WSL)

Requires Python 3.9+ โ€” no pip packages needed.

git clone https://github.com/zephyrq-z/fhash.git
cd fhash
bash install.sh

# Or run directly without installing:
python3 fhash.py --help

Option 3: GUI from Source

git clone https://github.com/zephyrq-z/fhash.git
cd fhash
python3 fhash_gui.py

Option 4: Download Pre-built App

Platform File How to use
macOS fhash.app Drag to /Applications, double-click to run
Windows fhash.exe Double-click to run, no install needed

Download from Releases (coming soon).

๐Ÿ“– Usage

macOS Right-Click (Quick Actions)

After running bash install_quick_actions.sh:

  1. Open Finder
  2. Select a folder
  3. Right-click โ†’ Quick Actions โ†’
    • fhash Encode โ€” Hash all subfolder names
    • fhash Decode โ€” Restore original folder names
  4. A notification will appear when done

Tip: If Quick Actions don't appear, go to System Settings โ†’ Privacy & Security โ†’ Extensions โ†’ Finder and enable fhash.

CLI

# Encode โ€” hash all subfolder names
fhash encode /path/to/folder

# Preview only (dry-run, no changes)
fhash encode /path/to/folder --dry-run

# Decode โ€” restore original names
fhash decode /path/to/folder

# List โ€” view current mapping (read-only)
fhash list /path/to/folder

# Current directory (no path needed)
cd /path/to/folder && fhash encode

# Use -n to specify path
fhash encode -n /path/to/folder

# Skip confirmation prompt
fhash encode /path/to/folder --yes

CLI Output Examples

$ fhash encode ~/projects --dry-run

Original Name                   โ†’  Hashed Name
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ”€โ”€โ”€ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
2024ๅนดๆŠฅๅ‘Š                         โ†’  7c330497
backend-api                     โ†’  d753230e
test_data                       โ†’  e7d87b73
ๆˆ‘็š„้กน็›ฎ                            โ†’  9ce557b3

4 folder(s) will be renamed.

[dry-run] No changes made.
$ fhash decode ~/projects --yes

Hashed Name   โ†’  Original Name
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ”€โ”€โ”€ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
7c330497      โ†’  2024ๅนดๆŠฅๅ‘Š
d753230e      โ†’  backend-api
e7d87b73      โ†’  test_data
9ce557b3      โ†’  ๆˆ‘็š„้กน็›ฎ

โœ… Done. 4 folder(s) restored to original names.

GUI

Launch the app and:

  1. Select a folder โ€” Click "Browseโ€ฆ" or paste a path
  2. Preview โ€” Click "๐Ÿ‘ Preview Encode" to see what will change
  3. Encode โ€” Click "๐Ÿ”’ Encode" to hash folder names
  4. Decode โ€” Click "๐Ÿ”“ Decode" to restore original names
  5. Refresh โ€” Click "๐Ÿ”„ Refresh" to reload the folder list

๐Ÿ”ง How It Works

Target Folder/
โ”œโ”€โ”€ .folder_hash_map.json   โ† Hidden mapping file (JSON)
โ”œโ”€โ”€ a3f1b2c7/               โ† Was "ๆˆ‘็š„้กน็›ฎ"
โ”œโ”€โ”€ 8d4e2f01/               โ† Was "test_data"
โ””โ”€โ”€ e7c93a12/               โ† Was "2024ๅนดๆŠฅๅ‘Š"

Mapping file (.folder_hash_map.json):

{
  "_meta": {
    "created": "2026-06-14T02:42:19.845934+00:00",
    "hash_algo": "sha256_8char"
  },
  "a3f1b2c7": "ๆˆ‘็š„้กน็›ฎ",
  "8d4e2f01": "test_data",
  "e7c93a12": "2024ๅนดๆŠฅๅ‘Š"
}

Algorithm:

  1. Compute SHA-256(folder_name) and take the first 8 hex characters
  2. If a collision occurs, auto-extend to 9, 10, ... up to 64 characters
  3. Rename each subfolder to its hash value
  4. Store the hash โ†’ original_name mapping in .folder_hash_map.json
  5. Hidden folders (. prefix) are always skipped
  6. A .bak backup of the mapping file is created before each operation

๐Ÿ—๏ธ Build from Source

macOS .app

git clone https://github.com/zephyrq-z/fhash.git
cd fhash
pip3 install pyinstaller pillow
bash build_mac.sh
# Output: dist/fhash.app

Windows .exe

On a Windows machine with Python 3.9+:

git clone https://github.com/zephyrq-z/fhash.git
cd fhash
pip install pyinstaller pillow
build_win.bat
# Output: dist\fhash.exe

Regenerate Icons

pip install pillow
python3 assets/gen_icon.py
# Generates assets/icon.icns (macOS) and assets/icon.ico (Windows)

๐Ÿ“ Project Structure

fhash/
โ”œโ”€โ”€ fhash.py                   # CLI tool (core logic)
โ”œโ”€โ”€ fhash_gui.py               # GUI application (tkinter, cross-platform)
โ”œโ”€โ”€ fhash-encode-runner.sh     # macOS Quick Action runner (encode)
โ”œโ”€โ”€ fhash-decode-runner.sh     # macOS Quick Action runner (decode)
โ”œโ”€โ”€ install.sh                 # CLI installer (symlink to ~/bin)
โ”œโ”€โ”€ install_quick_actions.sh   # macOS Finder Quick Actions installer
โ”œโ”€โ”€ build_mac.sh               # macOS .app builder (PyInstaller)
โ”œโ”€โ”€ build_win.bat              # Windows .exe builder (PyInstaller)
โ”œโ”€โ”€ assets/
โ”‚   โ”œโ”€โ”€ gen_icon.py            # App icon generator (Pillow)
โ”‚   โ”œโ”€โ”€ icon.icns              # macOS icon
โ”‚   โ””โ”€โ”€ icon.ico               # Windows icon
โ”œโ”€โ”€ README.md                  # English docs (this file)
โ”œโ”€โ”€ README.zh-CN.md            # ไธญๆ–‡ๆ–‡ๆกฃ
โ”œโ”€โ”€ LICENSE                    # MIT License
โ””โ”€โ”€ .gitignore

โ“ FAQ

Is this real encryption?
No, it's hashing with a mapping file. The SHA-256 hash itself is one-way (irreversible), but the .folder_hash_map.json stores the original names for restoration. Anyone with access to the mapping file can see the original names. If you need true encryption, consider adding a password-protected mapping file (see Contributing ideas).
What happens if I delete the mapping file?
The hashed folder names will remain, but you won't be able to restore them automatically. Always keep a backup of .folder_hash_map.json. Fortunately, a .bak backup is created before each operation.
Can I hash nested (deep) folders?
No, fhash only processes immediate subfolders (one level deep). This is by design for safety and simplicity. Use fhash on each directory separately if you need deeper hashing.
Will file contents be affected?
No. Only folder names are changed. All files, nested directories, and contents remain completely untouched.
What if two folder names produce the same hash?
The hash length auto-extends (8 โ†’ 9 โ†’ 10 chars) until all collisions are resolved. This is extremely rare with 8-char hashes (2.8 trillion combinations).
Why is the Quick Action not showing in Finder?
Go to System Settings โ†’ Privacy & Security โ†’ Extensions โ†’ Finder and enable fhash Encode / fhash Decode. You may also need to restart Finder (killall Finder) after installation.
Does it work with symlinks?
Symlinks to directories are not followed โ€” only real directories are processed. This prevents unintended renames across your filesystem.
Can I use it on Windows / Linux?
Yes! The CLI and GUI work on any platform with Python 3.9+. The Finder Quick Actions are macOS-only, but the CLI and GUI are fully cross-platform.

๐Ÿค Contributing

Issues and PRs are welcome! Here are some ideas for contributors:

  • GUI drag-and-drop folder support
  • Linux .AppImage / Nautilus right-click integration
  • Windows Explorer right-click context menu (registry)
  • Regex-based folder name filtering
  • Password-encrypted mapping file option
  • Batch mode for multiple directories
  • Undo history (multi-level rollback)
  • i18n: add more languages

๐Ÿ“„ License

MIT License โ€” free for personal and commercial use.

โญ Star History

Star History Chart


Made with โค๏ธ by zephyrq-z

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages