{"id":25039448,"url":"https://github.com/ishanoshada/spiral-cipher","last_synced_at":"2026-02-18T15:31:56.418Z","repository":{"id":274470491,"uuid":"923015263","full_name":"Ishanoshada/Spiral-Cipher","owner":"Ishanoshada","description":"A spiral cipher implementation for text encryption and decryption","archived":false,"fork":false,"pushed_at":"2025-01-27T17:06:44.000Z","size":14,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-03T17:44:05.371Z","etag":null,"topics":["cipher","crypto","cryptography","encryption","pypi","python","security","spiral","spiral-cipher"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/spiral-cipher/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ishanoshada.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-27T13:55:56.000Z","updated_at":"2025-04-28T14:36:29.000Z","dependencies_parsed_at":"2025-01-27T14:46:08.214Z","dependency_job_id":"7913ec8b-9284-4874-8b27-52dec7efdd81","html_url":"https://github.com/Ishanoshada/Spiral-Cipher","commit_stats":null,"previous_names":["ishanoshada/spiral-cipher"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ishanoshada%2FSpiral-Cipher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ishanoshada%2FSpiral-Cipher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ishanoshada%2FSpiral-Cipher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ishanoshada%2FSpiral-Cipher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ishanoshada","download_url":"https://codeload.github.com/Ishanoshada/Spiral-Cipher/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252516019,"owners_count":21760704,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cipher","crypto","cryptography","encryption","pypi","python","security","spiral","spiral-cipher"],"created_at":"2025-02-06T02:51:51.389Z","updated_at":"2025-10-13T15:34:28.648Z","avatar_url":"https://github.com/Ishanoshada.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spiral Cipher Documentation\n\n![PyPI](https://img.shields.io/pypi/v/spiral-cipher)\n\nThe **Spiral Cipher** is a Python package for text encryption and decryption using a spiral pattern. It writes text in a spiral pattern within a square matrix and reads it back row by row for encoding. The reverse process is used for decoding. The package also supports file-based encryption/decryption and customizable encryption keys.\n\n---\n\n## Features\n\n- **Text Encryption/Decryption**: Encrypt and decrypt text using a spiral pattern.\n- **File Encryption/Decryption**: Encrypt and decrypt files.\n- **Customizable Key**: Use a key to shift characters for additional security.\n- **UTF-8 Support**: Works with Unicode characters.\n- **Command-Line Interface (CLI)**: Easy-to-use CLI for text and file operations.\n- **Python API**: Programmatic access to encryption/decryption functions.\n\n---\n\n## Installation\n\nInstall the package using `pip`:\n\n```bash\npip install spiral-cipher\n```\n\n---\n\n## Usage\n\n### Python API\n\nThe package provides a Python API for programmatic usage.\n\n#### 1. **Encoding and Decoding Text**\n\n```python\nfrom spiral_cipher import encode, decode\n\n# Encode text\nencoded_text = encode(\"Hello, World!\", key=1111) # any key : int , ex : 9999999\nprint(encoded_text)  # Output: \"AxeeQQQhew!,khP\"\n\n# Decode text\ndecoded_text = decode(encoded_text, key=1111)\nprint(decoded_text)  # Output: \"Hello, World!\"\n```\n\n#### 2. **Using the `SpiralCipher` Class**\n\n```python\nfrom spiral_cipher import SpiralCipher\n\n# Initialize the cipher with a key\ncipher = SpiralCipher(key=3)\n\n# Encode text\nencoded_text = cipher.encode(\"Hello, World!\")\nprint(encoded_text)  # Output: \"KhooAAArog!,urZ\"\n\n# Decode text\ndecoded_text = cipher.decode(encoded_text)\nprint(decoded_text)  # Output: \"Hello, World!\"\n\n# Encrypt a file\ncipher.encrypt_file(\"input.txt\", \"encrypted.txt\")\n\n# Decrypt a file\ncipher.decrypt_file(\"encrypted.txt\", \"decrypted.txt\")\n```\n\n---\n\n### Command-Line Interface (CLI)\n\nThe package provides a CLI for easy text and file processing.\n\n#### 1. **Text Processing**\n\n```bash\n# Encode text\nspiral-cipher encode \"Hello, World!\" -k 3\n\n# Decode text\nspiral-cipher decode \"KhooAAArog!,urZ \" -k 3 #don't miss space +_+\n```\n\n#### 2. **File Processing**\n\n```bash\n# Encrypt a file\nspiral-cipher encode input.txt -f -o encrypted.txt -k 3\n\n# Decrypt a file\nspiral-cipher decode encrypted.txt -f -o decrypted.txt -k 3\n```\n\n#### 3. **CLI Options**\n\n| Argument | Description |\n|----------|-------------|\n| `action` | Action to perform (`encode` or `decode`) |\n| `input`  | Text to process or input file path |\n| `-k, --key` | Encryption key (default: `1`) |\n| `-f, --file` | Treat input as a file path |\n| `-o, --output` | Output file path (required for file operations) |\n| `-h, --help` | Show help message |\n\n---\n\n## How It Works\n\n### Encryption Process\n\n1. **Create a Square Matrix**:\n   - The input text is padded (if necessary) to fit into the smallest square matrix.\n\n2. **Write Text in Spiral Pattern**:\n   - The text is written in a spiral pattern (clockwise or counterclockwise) within the matrix.\n\n3. **Shift Characters**:\n   - Each character is shifted by the key value for additional security.\n\n4. **Read Row by Row**:\n   - The matrix is read row by row to generate the encrypted text.\n\n### Decryption Process\n\n1. **Create a Square Matrix**:\n   - The encrypted text is placed into a square matrix.\n\n2. **Read Text in Spiral Pattern**:\n   - The text is read in the reverse spiral pattern.\n\n3. **Unshift Characters**:\n   - Each character is unshifted by the key value.\n\n4. **Remove Padding**:\n   - Padding characters are removed to retrieve the original text.\n\n---\n\n## Examples\n\n### Example 1: Encoding and Decoding Text\n\n```python\nfrom spiral_cipher import encode, decode\n\n# Encode text\nencoded = encode(\"Hello, World!\", key=3)\nprint(encoded)  # Output: \"Khoog$ro/urZ#\"\n\n# Decode text\ndecoded = decode(encoded, key=3)\nprint(decoded)  # Output: \"Hello, World!\"\n```\n\n### Example 2: File Encryption and Decryption\n\n```python\nfrom spiral_cipher import SpiralCipher\n\n# Initialize the cipher\ncipher = SpiralCipher(key=3)\n\n# Encrypt a file\ncipher.encrypt_file(\"input.txt\", \"encrypted.txt\")\n\n# Decrypt a file\ncipher.decrypt_file(\"encrypted.txt\", \"decrypted.txt\")\n```\n\n### Example 3: CLI Usage\n\n```bash\n# Encode text\nspiral-cipher encode \"hellow\" -k 3\n\n# Decode text\nspiral-cipher decode \"khoAAoAzr\" -k 3\n\n# Encrypt a file\nspiral-cipher encode input.txt -f -o encrypted.txt -k 3\n\n# Decrypt a file\nspiral-cipher decode encrypted.txt -f -o decrypted.txt -k 3\n```\n\n---\n\n## Development\n\n### 1. **Clone the Repository**\n\n```bash\ngit clone https://github.com/ishanoshada/spiral-cipher.git\ncd spiral-cipher\n```\n\n### 2. **Install in Development Mode**\n\n```bash\npip install -e .\n```\n\n### 3. **Run Tests**\n\n```bash\npython -m unittest discover tests\n```\n\n---\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n---\n\n## Author\n\n- **Ishan Oshada** - [GitHub Profile](https://github.com/ishanoshada)\n\n---\n\n## Links\n\n- **GitHub Repository**: [https://github.com/ishanoshada/spiral-cipher](https://github.com/ishanoshada/spiral-cipher)\n- **PyPI Package**: [https://pypi.org/project/spiral-cipher/](https://pypi.org/project/spiral-cipher/)\n- **Bug Reports**: [https://github.com/ishanoshada/spiral-cipher/issues](https://github.com/ishanoshada/spiral-cipher/issues)\n\n---\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n**Repository Views** ![Views](https://profile-counter.glitch.me/spiral-cipher/count.svg)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fishanoshada%2Fspiral-cipher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fishanoshada%2Fspiral-cipher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fishanoshada%2Fspiral-cipher/lists"}