← Back to Home

CodeMask Documentation

Welcome to the CodeMask documentation! This guide will help you get started with masking sensitive code and text before sending it to AI models.

Table of Contents

Getting Started

CodeMask is a local-first desktop application that helps you protect sensitive information in your code and text before sharing it with AI models like ChatGPT, Claude, or other LLMs.

Why CodeMask? When sharing code with AI assistants, you might accidentally expose API keys, passwords, personal data, or proprietary identifiers. CodeMask replaces these with opaque tokens that can be reversed later, keeping your secrets safe.

Installation

Option 1: Download Pre-built Executables (Recommended)

The easiest way to get started is to download the pre-built executable for your platform:

Visit the Download page to get the latest version (v1.0.0) or check GitHub Releases for all available versions.

Option 2: Build from Source

If you prefer to build from source or want to contribute to the project:

Prerequisites

Build Steps

  1. Clone the repository:
    git clone https://github.com/codemasklab/codemask-oss.git
    cd codemask-oss
  2. Install dependencies:
    npm install
  3. Build the project:
    npm run build
  4. Run the application:
    npm start
Note: The open-source version supports Python code masking and text masking only. For additional languages (JavaScript, TypeScript, Java, Go, etc.), see the commercial version.

Basic Usage

Workflow

  1. Open CodeMask and create a new tab or open an existing file
  2. Select your mode: Code (Python) or Text
  3. Paste your content into the input editor
  4. Mask sensitive data: Use auto-mask or select specific identifiers
  5. Copy the masked output and send it to your AI assistant
  6. Paste the AI response back into the output editor
  7. Unmask to restore original identifiers

Code Mode (Python)

Code mode uses AST (Abstract Syntax Tree) parsing to understand your Python code structure and mask identifiers intelligently.

Auto-Mask

Click the "Mask All" button to automatically mask all identifiers in your Python code:

Style Preservation: CodeMask preserves naming conventions. If your variable is snake_case, the masked token will also be snake_case. Same for PascalCase, camelCase, etc.

Select-to-Mask

For more control, you can manually select specific identifiers to mask:

  1. Select an identifier in the input editor (e.g., api_key)
  2. It will appear in the "Selected Items" section
  3. Click "Mask Selected" to mask only those identifiers

Example

Before:

def authenticate(user, password):
    api_key = "sk-1234567890abcdef"
    return verify_credentials(user, password, api_key)

After Masking:

def v6g9j2r41m5qk(v7h0k3s42n6rl, v8i1l4t53o7sm):
    v9j2m5u64p8tn = "sk-1234567890abcdef"
    return v0k3n6v75q9uo(v7h0k3s42n6rl, v8i1l4t53o7sm, v9j2m5u64p8tn)
String Literals: String values (like API keys in quotes) are not automatically masked. You need to manually select them if you want to mask their content.

Text Mode

Text mode is for free-form text masking. It's perfect for masking sensitive information in documents, emails, or any text content.

Manual Selection

Select words or phrases in the input editor to mask them. Selected items appear in the "Selected Items" section.

Format-Preserving Masking

CodeMask can detect and preserve the format of certain identifier types:

Example

Before:

Contact John Doe at john.doe@example.com or call 555-123-4567

After Masking:

Contact v6g9j2r41m5qk at v7h0k3s42n6rl@masked.com or call 555-987-6543

Unmasking

After receiving a response from an AI assistant, you can unmask the content to restore original identifiers:

  1. Paste the AI's response into the output editor
  2. Click the "Unmask" button
  3. The masked tokens will be replaced with your original identifiers
Mapping Storage: CodeMask stores the mapping between original identifiers and masked tokens in an encrypted file on your local machine. This mapping is required for unmasking.

Mapping Groups

Mapping groups help you organize different masking sessions. Each group maintains its own set of mappings.

Creating a New Group

Wiping Mappings

You can clear mappings for a specific group or all groups:

Warning: Wiping mappings is permanent. You won't be able to unmask content that was masked with those mappings after wiping.

Keyboard Shortcuts

File Operations

Editing

View

Search

Troubleshooting

Mapping File Not Found

If you get an error about the mapping file, CodeMask will create a new one automatically. However, you won't be able to unmask content from previous sessions.

Keychain Access Issues

On macOS and Linux, CodeMask uses the OS keychain to store encryption keys. If you see keychain access prompts, allow access for CodeMask to function properly.

Build Errors

If you encounter build errors, ensure you have:

Getting Help

If you encounter issues:

Contributing: CodeMask is open source! We welcome contributions. See the Contributing Guide for more information.