Skip to content

TogglesPlatform/ToggleCipher

Repository files navigation

ToggleCipher

A Swift command-line tool that provides secure encryption and decryption capabilities using modern cryptographic algorithms. Built with Apple's CryptoKit framework for high-performance, secure cryptographic operations.

Features

  • ChaCha20-Poly1305 Encryption: Industry-standard authenticated encryption algorithm
  • Command-Line Interface: Easy-to-use CLI for encryption and decryption operations
  • Swift Package Manager: Modern Swift package with comprehensive testing
  • Secure Key Handling: Uses SHA-256 hashing for key derivation
  • Base64 Encoding: Human-readable output format for encrypted data

Requirements

  • macOS 12.0 or later
  • Swift 6.0 or later
  • Xcode 14.0 or later (for development)

Installation

Download Pre-built Binary

Download the latest pre-built binary from GitHub Releases:

# Download and install (replace VERSION with the latest version)
curl -L https://github.com/TogglesPlatform/ToggleCipher/releases/download/VERSION/ToggleCipher -o /usr/local/bin/ToggleCipher
chmod +x /usr/local/bin/ToggleGen

Building from Source

  1. Clone the repository:

    git clone https://github.com/TogglesPlatform/ToggleCipher.git
    cd ToggleCipher
  2. Build the executable:

    swift build -c release
  3. The executable will be available at .build/release/ToggleCipher

Usage

ToggleCipher provides two main commands: encrypt and decrypt.

Encrypting Data

ToggleCipher encrypt --algorithm chaChaPoly --key "your-secret-key" --value "data to encrypt"

Example:

ToggleCipher encrypt --algorithm chaChaPoly --key "mySecretKey123" --value "Hello, World"

Output:

Plaintext value: "Hello, World"
Encrypted value: "9bnthawCQI+H5gRFM+4i7ng491R7ZnQ4Iqd5nCuKZ/hAYf6AzDV/5w=="

Decrypting Data

ToggleCipher decrypt --algorithm chaChaPoly --key "your-secret-key" --value "encrypted-data"

Example:

ToggleCipher decrypt --algorithm chaChaPoly --key "mySecretKey123" --value "base64-encoded-encrypted-data"

Output:

Encrypted value: "9bnthawCQI+H5gRFM+4i7ng491R7ZnQ4Iqd5nCuKZ/hAYf6AzDV/5w=="
Decrypted value: "Hello, World"

Command-Line Options

Option Description Required
--algorithm The encryption algorithm to use (currently supports: chaChaPoly) Yes
--key The secret key used for encryption/decryption Yes
--value The data to encrypt or decrypt Yes

Supported Algorithms

Currently, ToggleCipher supports the following encryption algorithms:

  • ChaCha20-Poly1305 (chaChaPoly): A high-speed, authenticated encryption algorithm that provides both confidentiality and authenticity

Security Considerations

  • Key Management: Ensure your encryption keys are stored securely and never hard-coded in your applications
  • Key Derivation: Keys are processed through SHA-256 hashing before use, providing consistent key lengths
  • Authenticated Encryption: ChaCha20-Poly1305 provides both encryption and authentication, protecting against tampering
  • Secure Random: The encryption process uses cryptographically secure random number generation

License

This project is licensed under the terms specified in the LICENSE file.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

For more information about the ChaCha20-Poly1305 algorithm, see RFC 8439.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages