decodify 0.0.1__tar.gz → 0.1.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- decodify-0.1.3/PKG-INFO +183 -0
- decodify-0.1.3/README.md +154 -0
- decodify-0.1.3/decodify/__init__.py +6 -0
- decodify-0.1.3/decodify/algorithms/__init__.py +6 -0
- decodify-0.1.3/decodify/algorithms/base64.py +18 -0
- decodify-0.1.3/decodify/algorithms/binary.py +23 -0
- decodify-0.1.3/decodify/algorithms/hex.py +15 -0
- decodify-0.1.3/decodify/algorithms/morse.py +29 -0
- decodify-0.1.3/decodify/algorithms/url.py +14 -0
- decodify-0.1.3/decodify/cli.py +47 -0
- decodify-0.1.3/decodify/decodify.py +78 -0
- decodify-0.1.3/decodify.egg-info/PKG-INFO +183 -0
- decodify-0.1.3/decodify.egg-info/SOURCES.txt +16 -0
- decodify-0.1.3/decodify.egg-info/entry_points.txt +2 -0
- {decodify-0.0.1 → decodify-0.1.3}/setup.cfg +4 -4
- decodify-0.1.3/setup.py +34 -0
- decodify-0.0.1/LICENSE +0 -21
- decodify-0.0.1/PKG-INFO +0 -23
- decodify-0.0.1/README.md +0 -9
- decodify-0.0.1/decodify/__init__.py +0 -1
- decodify-0.0.1/decodify.egg-info/PKG-INFO +0 -23
- decodify-0.0.1/decodify.egg-info/SOURCES.txt +0 -9
- decodify-0.0.1/decodify.egg-info/requires.txt +0 -1
- decodify-0.0.1/setup.py +0 -19
- {decodify-0.0.1 → decodify-0.1.3}/decodify.egg-info/dependency_links.txt +0 -0
- {decodify-0.0.1 → decodify-0.1.3}/decodify.egg-info/top_level.txt +0 -0
decodify-0.1.3/PKG-INFO
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: decodify
|
|
3
|
+
Version: 0.1.3
|
|
4
|
+
Summary: An advanced package to detect encoding algorithms and decode messages.
|
|
5
|
+
Home-page: https://github.com/ishanoshada/decodify
|
|
6
|
+
Author: Ishan Oshada
|
|
7
|
+
Author-email: ishan.kodithuwakku.offical@gmail.com
|
|
8
|
+
Keywords: encoding,decoding,cryptography,cipher,decode,encoder,decoder,base64,hash
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Topic :: Security :: Cryptography
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
18
|
+
Classifier: Intended Audience :: Developers
|
|
19
|
+
Classifier: Development Status :: 4 - Beta
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
Dynamic: author
|
|
22
|
+
Dynamic: author-email
|
|
23
|
+
Dynamic: classifier
|
|
24
|
+
Dynamic: description
|
|
25
|
+
Dynamic: description-content-type
|
|
26
|
+
Dynamic: home-page
|
|
27
|
+
Dynamic: keywords
|
|
28
|
+
Dynamic: summary
|
|
29
|
+
|
|
30
|
+
# Decodify
|
|
31
|
+
|
|
32
|
+
**Decodify** is a Python package designed to detect and decode messages encoded with various algorithms. It supports multiple encoding schemes and provides a simple interface for decoding messages directly or from files.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Features
|
|
37
|
+
|
|
38
|
+
- **Multiple Encoding Algorithms**: Supports Base64, Hexadecimal, URL Encoding, Binary, and Morse Code.
|
|
39
|
+
- **Automatic Detection**: Detects the encoding algorithm used in a message.
|
|
40
|
+
- **Command-Line Interface (CLI)**: Decode messages directly from the terminal or from files.
|
|
41
|
+
- **File Support**: Decode messages stored in files and save the output to a file.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
You can install `decodify` using `pip`:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install decodify
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Usage
|
|
56
|
+
|
|
57
|
+
### Python API
|
|
58
|
+
|
|
59
|
+
You can use the `decodify` package in your Python code to decode messages.
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from decodify import decode_message
|
|
63
|
+
|
|
64
|
+
# Decode a Base64 encoded message
|
|
65
|
+
encoded_message = "aGVsbG8="
|
|
66
|
+
decoded, probabilities = decode_message(encoded_message)
|
|
67
|
+
|
|
68
|
+
print(f"Decoded Message: {decoded}")
|
|
69
|
+
print(f"Algorithm Probabilities: {probabilities}")
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Command-Line Interface (CLI)
|
|
73
|
+
|
|
74
|
+
You can use the `decodify` CLI to decode messages directly from the terminal.
|
|
75
|
+
|
|
76
|
+
#### Decode a Message
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
decodify "aGVsbG8="
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### Decode a Message from a File
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
decodify encoded.txt -f
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
#### Specify an Algorithm
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
decodify "aGVsbG8=" --algorithm base64
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
#### Save the Decoded Message to a File
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
decodify "aGVsbG8=" --output decoded.txt
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Supported Algorithms
|
|
103
|
+
|
|
104
|
+
| Algorithm | Description |
|
|
105
|
+
|---------------|-----------------------------------------------------------------------------|
|
|
106
|
+
| **Base64** | Decodes Base64 encoded strings. |
|
|
107
|
+
| **Hexadecimal** | Decodes hexadecimal encoded strings. |
|
|
108
|
+
| **URL Encoding** | Decodes URL-encoded strings (e.g., `hello%20world` → `hello world`). |
|
|
109
|
+
| **Binary** | Decodes binary encoded strings (e.g., `01101000 01100101` → `he`). |
|
|
110
|
+
| **Morse Code** | Decodes Morse code strings (e.g., `.... . .-.. .-.. ---` → `HELLO`). |
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Examples
|
|
115
|
+
|
|
116
|
+
### Decoding a Base64 Message
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
from decodify import decode_message
|
|
120
|
+
|
|
121
|
+
encoded_message = "aGVsbG8="
|
|
122
|
+
decoded, probabilities = decode_message(encoded_message)
|
|
123
|
+
|
|
124
|
+
print(f"Decoded Message: {decoded}")
|
|
125
|
+
# Output: Decoded Message: hello
|
|
126
|
+
print(f"Algorithm Probabilities: {probabilities}")
|
|
127
|
+
# Output: Algorithm Probabilities: {'base64': 1.0, ...}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Decoding from a File
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
decodify encoded.txt -f
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Saving Decoded Output to a File
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
decodify "aGVsbG8=" --output decoded.txt
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## License
|
|
145
|
+
|
|
146
|
+
This project is licensed under the **MIT License**. See the [LICENSE](LICENSE) file for details.
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## Contributing
|
|
151
|
+
|
|
152
|
+
Contributions are welcome! If you'd like to contribute, please follow these steps:
|
|
153
|
+
|
|
154
|
+
1. Fork the repository.
|
|
155
|
+
2. Create a new branch for your feature or bugfix.
|
|
156
|
+
3. Commit your changes.
|
|
157
|
+
4. Submit a pull request.
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## Issues
|
|
162
|
+
|
|
163
|
+
If you encounter any issues or have suggestions for improvements, please open an issue on the [GitHub repository](https://github.com/ishanoshada/decodify).
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Acknowledgments
|
|
168
|
+
|
|
169
|
+
- Thanks to the Python community for creating amazing tools and libraries.
|
|
170
|
+
- Special thanks to contributors who helped improve this package.
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Contact
|
|
175
|
+
|
|
176
|
+
For questions or feedback, feel free to reach out:
|
|
177
|
+
|
|
178
|
+
- **Email**: ishan.kodithuwakku.offical@gmail.com
|
|
179
|
+
- **GitHub**: [ishanoshada](https://github.com/ishanoshada)
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
Enjoy decoding with **Decodify**! 🚀
|
decodify-0.1.3/README.md
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# Decodify
|
|
2
|
+
|
|
3
|
+
**Decodify** is a Python package designed to detect and decode messages encoded with various algorithms. It supports multiple encoding schemes and provides a simple interface for decoding messages directly or from files.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Multiple Encoding Algorithms**: Supports Base64, Hexadecimal, URL Encoding, Binary, and Morse Code.
|
|
10
|
+
- **Automatic Detection**: Detects the encoding algorithm used in a message.
|
|
11
|
+
- **Command-Line Interface (CLI)**: Decode messages directly from the terminal or from files.
|
|
12
|
+
- **File Support**: Decode messages stored in files and save the output to a file.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
You can install `decodify` using `pip`:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install decodify
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
### Python API
|
|
29
|
+
|
|
30
|
+
You can use the `decodify` package in your Python code to decode messages.
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from decodify import decode_message
|
|
34
|
+
|
|
35
|
+
# Decode a Base64 encoded message
|
|
36
|
+
encoded_message = "aGVsbG8="
|
|
37
|
+
decoded, probabilities = decode_message(encoded_message)
|
|
38
|
+
|
|
39
|
+
print(f"Decoded Message: {decoded}")
|
|
40
|
+
print(f"Algorithm Probabilities: {probabilities}")
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Command-Line Interface (CLI)
|
|
44
|
+
|
|
45
|
+
You can use the `decodify` CLI to decode messages directly from the terminal.
|
|
46
|
+
|
|
47
|
+
#### Decode a Message
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
decodify "aGVsbG8="
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
#### Decode a Message from a File
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
decodify encoded.txt -f
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
#### Specify an Algorithm
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
decodify "aGVsbG8=" --algorithm base64
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
#### Save the Decoded Message to a File
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
decodify "aGVsbG8=" --output decoded.txt
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Supported Algorithms
|
|
74
|
+
|
|
75
|
+
| Algorithm | Description |
|
|
76
|
+
|---------------|-----------------------------------------------------------------------------|
|
|
77
|
+
| **Base64** | Decodes Base64 encoded strings. |
|
|
78
|
+
| **Hexadecimal** | Decodes hexadecimal encoded strings. |
|
|
79
|
+
| **URL Encoding** | Decodes URL-encoded strings (e.g., `hello%20world` → `hello world`). |
|
|
80
|
+
| **Binary** | Decodes binary encoded strings (e.g., `01101000 01100101` → `he`). |
|
|
81
|
+
| **Morse Code** | Decodes Morse code strings (e.g., `.... . .-.. .-.. ---` → `HELLO`). |
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Examples
|
|
86
|
+
|
|
87
|
+
### Decoding a Base64 Message
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
from decodify import decode_message
|
|
91
|
+
|
|
92
|
+
encoded_message = "aGVsbG8="
|
|
93
|
+
decoded, probabilities = decode_message(encoded_message)
|
|
94
|
+
|
|
95
|
+
print(f"Decoded Message: {decoded}")
|
|
96
|
+
# Output: Decoded Message: hello
|
|
97
|
+
print(f"Algorithm Probabilities: {probabilities}")
|
|
98
|
+
# Output: Algorithm Probabilities: {'base64': 1.0, ...}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Decoding from a File
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
decodify encoded.txt -f
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Saving Decoded Output to a File
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
decodify "aGVsbG8=" --output decoded.txt
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## License
|
|
116
|
+
|
|
117
|
+
This project is licensed under the **MIT License**. See the [LICENSE](LICENSE) file for details.
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Contributing
|
|
122
|
+
|
|
123
|
+
Contributions are welcome! If you'd like to contribute, please follow these steps:
|
|
124
|
+
|
|
125
|
+
1. Fork the repository.
|
|
126
|
+
2. Create a new branch for your feature or bugfix.
|
|
127
|
+
3. Commit your changes.
|
|
128
|
+
4. Submit a pull request.
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Issues
|
|
133
|
+
|
|
134
|
+
If you encounter any issues or have suggestions for improvements, please open an issue on the [GitHub repository](https://github.com/ishanoshada/decodify).
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## Acknowledgments
|
|
139
|
+
|
|
140
|
+
- Thanks to the Python community for creating amazing tools and libraries.
|
|
141
|
+
- Special thanks to contributors who helped improve this package.
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Contact
|
|
146
|
+
|
|
147
|
+
For questions or feedback, feel free to reach out:
|
|
148
|
+
|
|
149
|
+
- **Email**: ishan.kodithuwakku.offical@gmail.com
|
|
150
|
+
- **GitHub**: [ishanoshada](https://github.com/ishanoshada)
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
Enjoy decoding with **Decodify**! 🚀
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# decodify/algorithms/base64.py
|
|
2
|
+
import base64
|
|
3
|
+
|
|
4
|
+
def is_base64(encoded: str) -> bool:
|
|
5
|
+
"""
|
|
6
|
+
Check if the input is a valid Base64 encoded string.
|
|
7
|
+
"""
|
|
8
|
+
try:
|
|
9
|
+
base64.b64decode(encoded, validate=True)
|
|
10
|
+
return True
|
|
11
|
+
except:
|
|
12
|
+
return False
|
|
13
|
+
|
|
14
|
+
def decode_base64(encoded: str) -> str:
|
|
15
|
+
"""
|
|
16
|
+
Decode a Base64 encoded string.
|
|
17
|
+
"""
|
|
18
|
+
return base64.b64decode(encoded).decode("utf-8")
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# decodify/algorithms/binary.py
|
|
2
|
+
import re
|
|
3
|
+
|
|
4
|
+
def is_binary(encoded: str) -> bool:
|
|
5
|
+
"""
|
|
6
|
+
Check if the input is a valid binary encoded string.
|
|
7
|
+
"""
|
|
8
|
+
# Binary strings consist of 0s and 1s, optionally separated by spaces
|
|
9
|
+
binary_pattern = re.compile(r"^[01\s]+$")
|
|
10
|
+
return bool(binary_pattern.match(encoded))
|
|
11
|
+
|
|
12
|
+
def decode_binary(encoded: str) -> str:
|
|
13
|
+
"""
|
|
14
|
+
Decode a binary encoded string.
|
|
15
|
+
"""
|
|
16
|
+
# Remove spaces and split into 8-bit chunks
|
|
17
|
+
binary_values = encoded.replace(" ", "")
|
|
18
|
+
binary_values = [binary_values[i:i+8] for i in range(0, len(binary_values), 8)]
|
|
19
|
+
decoded = ""
|
|
20
|
+
for binary in binary_values:
|
|
21
|
+
decimal = int(binary, 2)
|
|
22
|
+
decoded += chr(decimal)
|
|
23
|
+
return decoded
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# decodify/algorithms/hex.py
|
|
2
|
+
import re
|
|
3
|
+
|
|
4
|
+
def is_hex(encoded: str) -> bool:
|
|
5
|
+
"""
|
|
6
|
+
Check if the input is a valid Hexadecimal encoded string.
|
|
7
|
+
"""
|
|
8
|
+
hex_pattern = re.compile(r"^[0-9a-fA-F]+$")
|
|
9
|
+
return bool(hex_pattern.match(encoded))
|
|
10
|
+
|
|
11
|
+
def decode_hex(encoded: str) -> str:
|
|
12
|
+
"""
|
|
13
|
+
Decode a Hexadecimal encoded string.
|
|
14
|
+
"""
|
|
15
|
+
return bytes.fromhex(encoded).decode("utf-8")
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# decodify/algorithms/morse.py
|
|
2
|
+
MORSE_CODE_DICT = {
|
|
3
|
+
'.-': 'A', '-...': 'B', '-.-.': 'C', '-..': 'D', '.': 'E',
|
|
4
|
+
'..-.': 'F', '--.': 'G', '....': 'H', '..': 'I', '.---': 'J',
|
|
5
|
+
'-.-': 'K', '.-..': 'L', '--': 'M', '-.': 'N', '---': 'O',
|
|
6
|
+
'.--.': 'P', '--.-': 'Q', '.-.': 'R', '...': 'S', '-': 'T',
|
|
7
|
+
'..-': 'U', '...-': 'V', '.--': 'W', '-..-': 'X', '-.--': 'Y',
|
|
8
|
+
'--..': 'Z', '-----': '0', '.----': '1', '..---': '2', '...--': '3',
|
|
9
|
+
'....-': '4', '.....': '5', '-....': '6', '--...': '7', '---..': '8',
|
|
10
|
+
'----.': '9', '/': ' '
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
def is_morse(encoded: str) -> bool:
|
|
14
|
+
"""
|
|
15
|
+
Check if the input is a valid Morse code encoded string.
|
|
16
|
+
"""
|
|
17
|
+
return all(char in [".", "-", " ", "/"] for char in encoded)
|
|
18
|
+
|
|
19
|
+
def decode_morse(encoded: str) -> str:
|
|
20
|
+
"""
|
|
21
|
+
Decode a Morse code encoded string.
|
|
22
|
+
"""
|
|
23
|
+
words = encoded.split(" / ")
|
|
24
|
+
decoded_message = []
|
|
25
|
+
for word in words:
|
|
26
|
+
letters = word.split()
|
|
27
|
+
decoded_word = "".join([MORSE_CODE_DICT.get(letter, "") for letter in letters])
|
|
28
|
+
decoded_message.append(decoded_word)
|
|
29
|
+
return " ".join(decoded_message)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# decodify/algorithms/url.py
|
|
2
|
+
from urllib.parse import unquote
|
|
3
|
+
|
|
4
|
+
def is_url_encoded(encoded: str) -> bool:
|
|
5
|
+
"""
|
|
6
|
+
Check if the input is a valid URL encoded string.
|
|
7
|
+
"""
|
|
8
|
+
return "%" in encoded
|
|
9
|
+
|
|
10
|
+
def decode_url(encoded: str) -> str:
|
|
11
|
+
"""
|
|
12
|
+
Decode a URL encoded string.
|
|
13
|
+
"""
|
|
14
|
+
return unquote(encoded)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# decodify/cli.py
|
|
2
|
+
import argparse
|
|
3
|
+
from decodify import decode_message
|
|
4
|
+
|
|
5
|
+
def main():
|
|
6
|
+
parser = argparse.ArgumentParser(description="Decodify: A tool to detect and decode encoded messages.")
|
|
7
|
+
parser.add_argument("input", nargs="?", help="The encoded message or file path.")
|
|
8
|
+
parser.add_argument("-f", "--file", action="store_true", help="Read input from a file.")
|
|
9
|
+
parser.add_argument("-o", "--output", help="Save the decoded message to a file.")
|
|
10
|
+
parser.add_argument("-a", "--algorithm", help="Specify the decoding algorithm to use.")
|
|
11
|
+
args = parser.parse_args()
|
|
12
|
+
|
|
13
|
+
if not args.input:
|
|
14
|
+
parser.print_help()
|
|
15
|
+
return
|
|
16
|
+
|
|
17
|
+
# Read input
|
|
18
|
+
if args.file:
|
|
19
|
+
try:
|
|
20
|
+
with open(args.input, "r") as f:
|
|
21
|
+
encoded = f.read().strip()
|
|
22
|
+
except FileNotFoundError:
|
|
23
|
+
print(f"Error: File '{args.input}' not found.")
|
|
24
|
+
return
|
|
25
|
+
else:
|
|
26
|
+
encoded = args.input
|
|
27
|
+
|
|
28
|
+
# Decode the message
|
|
29
|
+
decoded, probabilities = decode_message(encoded, algorithm=args.algorithm)
|
|
30
|
+
|
|
31
|
+
# Print results
|
|
32
|
+
print(f"Decoded Message: {decoded}")
|
|
33
|
+
print("Algorithm Probabilities:")
|
|
34
|
+
for alg, prob in probabilities.items():
|
|
35
|
+
print(f" {alg}: {prob:.2f}")
|
|
36
|
+
|
|
37
|
+
# Save output to file
|
|
38
|
+
if args.output:
|
|
39
|
+
try:
|
|
40
|
+
with open(args.output, "w") as f:
|
|
41
|
+
f.write(decoded)
|
|
42
|
+
print(f"Decoded message saved to '{args.output}'.")
|
|
43
|
+
except Exception as e:
|
|
44
|
+
print(f"Error saving output: {e}")
|
|
45
|
+
|
|
46
|
+
if __name__ == "__main__":
|
|
47
|
+
main()
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# decodify/decodify.py
|
|
2
|
+
from typing import Dict, Tuple
|
|
3
|
+
from .algorithms import (
|
|
4
|
+
is_base64, decode_base64,
|
|
5
|
+
is_hex, decode_hex,
|
|
6
|
+
is_url_encoded, decode_url,
|
|
7
|
+
is_binary, decode_binary,
|
|
8
|
+
is_morse, decode_morse,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
class Decodify:
|
|
12
|
+
@staticmethod
|
|
13
|
+
def detect_algorithm(encoded: str) -> Dict[str, float]:
|
|
14
|
+
"""
|
|
15
|
+
Detect the likelihood of each encoding algorithm being used.
|
|
16
|
+
"""
|
|
17
|
+
detection_results = {
|
|
18
|
+
"base64": is_base64(encoded),
|
|
19
|
+
"hex": is_hex(encoded),
|
|
20
|
+
"url": is_url_encoded(encoded),
|
|
21
|
+
"binary": is_binary(encoded),
|
|
22
|
+
"morse": is_morse(encoded),
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
# Normalize probabilities to sum to 1
|
|
26
|
+
total = sum(detection_results.values())
|
|
27
|
+
if total > 0:
|
|
28
|
+
for key in detection_results:
|
|
29
|
+
detection_results[key] /= total
|
|
30
|
+
else:
|
|
31
|
+
# If no algorithm is detected, set all probabilities to 0
|
|
32
|
+
for key in detection_results:
|
|
33
|
+
detection_results[key] = 0.0
|
|
34
|
+
|
|
35
|
+
return detection_results
|
|
36
|
+
|
|
37
|
+
@staticmethod
|
|
38
|
+
def decode_message(encoded: str, algorithm: str = None) -> Tuple[str, Dict[str, float]]:
|
|
39
|
+
"""
|
|
40
|
+
Decode the message using the specified algorithm or by detecting the most likely one.
|
|
41
|
+
"""
|
|
42
|
+
if algorithm:
|
|
43
|
+
# Use the specified algorithm
|
|
44
|
+
if algorithm == "base64":
|
|
45
|
+
decoded = decode_base64(encoded)
|
|
46
|
+
elif algorithm == "hex":
|
|
47
|
+
decoded = decode_hex(encoded)
|
|
48
|
+
elif algorithm == "url":
|
|
49
|
+
decoded = decode_url(encoded)
|
|
50
|
+
elif algorithm == "binary":
|
|
51
|
+
decoded = decode_binary(encoded)
|
|
52
|
+
elif algorithm == "morse":
|
|
53
|
+
decoded = decode_morse(encoded)
|
|
54
|
+
else:
|
|
55
|
+
decoded = "Unsupported algorithm."
|
|
56
|
+
return decoded, {algorithm: 1.0}
|
|
57
|
+
else:
|
|
58
|
+
# Detect the algorithm
|
|
59
|
+
algorithm_probabilities = Decodify.detect_algorithm(encoded)
|
|
60
|
+
most_likely_algorithm = max(algorithm_probabilities, key=algorithm_probabilities.get)
|
|
61
|
+
|
|
62
|
+
if algorithm_probabilities[most_likely_algorithm] == 0.0:
|
|
63
|
+
return "Unable to decode the message.", algorithm_probabilities
|
|
64
|
+
|
|
65
|
+
if most_likely_algorithm == "base64":
|
|
66
|
+
decoded = decode_base64(encoded)
|
|
67
|
+
elif most_likely_algorithm == "hex":
|
|
68
|
+
decoded = decode_hex(encoded)
|
|
69
|
+
elif most_likely_algorithm == "url":
|
|
70
|
+
decoded = decode_url(encoded)
|
|
71
|
+
elif most_likely_algorithm == "binary":
|
|
72
|
+
decoded = decode_binary(encoded)
|
|
73
|
+
elif most_likely_algorithm == "morse":
|
|
74
|
+
decoded = decode_morse(encoded)
|
|
75
|
+
else:
|
|
76
|
+
decoded = "Unable to decode the message."
|
|
77
|
+
|
|
78
|
+
return decoded, algorithm_probabilities
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: decodify
|
|
3
|
+
Version: 0.1.3
|
|
4
|
+
Summary: An advanced package to detect encoding algorithms and decode messages.
|
|
5
|
+
Home-page: https://github.com/ishanoshada/decodify
|
|
6
|
+
Author: Ishan Oshada
|
|
7
|
+
Author-email: ishan.kodithuwakku.offical@gmail.com
|
|
8
|
+
Keywords: encoding,decoding,cryptography,cipher,decode,encoder,decoder,base64,hash
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Topic :: Security :: Cryptography
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
18
|
+
Classifier: Intended Audience :: Developers
|
|
19
|
+
Classifier: Development Status :: 4 - Beta
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
Dynamic: author
|
|
22
|
+
Dynamic: author-email
|
|
23
|
+
Dynamic: classifier
|
|
24
|
+
Dynamic: description
|
|
25
|
+
Dynamic: description-content-type
|
|
26
|
+
Dynamic: home-page
|
|
27
|
+
Dynamic: keywords
|
|
28
|
+
Dynamic: summary
|
|
29
|
+
|
|
30
|
+
# Decodify
|
|
31
|
+
|
|
32
|
+
**Decodify** is a Python package designed to detect and decode messages encoded with various algorithms. It supports multiple encoding schemes and provides a simple interface for decoding messages directly or from files.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Features
|
|
37
|
+
|
|
38
|
+
- **Multiple Encoding Algorithms**: Supports Base64, Hexadecimal, URL Encoding, Binary, and Morse Code.
|
|
39
|
+
- **Automatic Detection**: Detects the encoding algorithm used in a message.
|
|
40
|
+
- **Command-Line Interface (CLI)**: Decode messages directly from the terminal or from files.
|
|
41
|
+
- **File Support**: Decode messages stored in files and save the output to a file.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
You can install `decodify` using `pip`:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install decodify
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Usage
|
|
56
|
+
|
|
57
|
+
### Python API
|
|
58
|
+
|
|
59
|
+
You can use the `decodify` package in your Python code to decode messages.
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from decodify import decode_message
|
|
63
|
+
|
|
64
|
+
# Decode a Base64 encoded message
|
|
65
|
+
encoded_message = "aGVsbG8="
|
|
66
|
+
decoded, probabilities = decode_message(encoded_message)
|
|
67
|
+
|
|
68
|
+
print(f"Decoded Message: {decoded}")
|
|
69
|
+
print(f"Algorithm Probabilities: {probabilities}")
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Command-Line Interface (CLI)
|
|
73
|
+
|
|
74
|
+
You can use the `decodify` CLI to decode messages directly from the terminal.
|
|
75
|
+
|
|
76
|
+
#### Decode a Message
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
decodify "aGVsbG8="
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### Decode a Message from a File
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
decodify encoded.txt -f
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
#### Specify an Algorithm
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
decodify "aGVsbG8=" --algorithm base64
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
#### Save the Decoded Message to a File
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
decodify "aGVsbG8=" --output decoded.txt
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Supported Algorithms
|
|
103
|
+
|
|
104
|
+
| Algorithm | Description |
|
|
105
|
+
|---------------|-----------------------------------------------------------------------------|
|
|
106
|
+
| **Base64** | Decodes Base64 encoded strings. |
|
|
107
|
+
| **Hexadecimal** | Decodes hexadecimal encoded strings. |
|
|
108
|
+
| **URL Encoding** | Decodes URL-encoded strings (e.g., `hello%20world` → `hello world`). |
|
|
109
|
+
| **Binary** | Decodes binary encoded strings (e.g., `01101000 01100101` → `he`). |
|
|
110
|
+
| **Morse Code** | Decodes Morse code strings (e.g., `.... . .-.. .-.. ---` → `HELLO`). |
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Examples
|
|
115
|
+
|
|
116
|
+
### Decoding a Base64 Message
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
from decodify import decode_message
|
|
120
|
+
|
|
121
|
+
encoded_message = "aGVsbG8="
|
|
122
|
+
decoded, probabilities = decode_message(encoded_message)
|
|
123
|
+
|
|
124
|
+
print(f"Decoded Message: {decoded}")
|
|
125
|
+
# Output: Decoded Message: hello
|
|
126
|
+
print(f"Algorithm Probabilities: {probabilities}")
|
|
127
|
+
# Output: Algorithm Probabilities: {'base64': 1.0, ...}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Decoding from a File
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
decodify encoded.txt -f
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Saving Decoded Output to a File
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
decodify "aGVsbG8=" --output decoded.txt
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## License
|
|
145
|
+
|
|
146
|
+
This project is licensed under the **MIT License**. See the [LICENSE](LICENSE) file for details.
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## Contributing
|
|
151
|
+
|
|
152
|
+
Contributions are welcome! If you'd like to contribute, please follow these steps:
|
|
153
|
+
|
|
154
|
+
1. Fork the repository.
|
|
155
|
+
2. Create a new branch for your feature or bugfix.
|
|
156
|
+
3. Commit your changes.
|
|
157
|
+
4. Submit a pull request.
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## Issues
|
|
162
|
+
|
|
163
|
+
If you encounter any issues or have suggestions for improvements, please open an issue on the [GitHub repository](https://github.com/ishanoshada/decodify).
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Acknowledgments
|
|
168
|
+
|
|
169
|
+
- Thanks to the Python community for creating amazing tools and libraries.
|
|
170
|
+
- Special thanks to contributors who helped improve this package.
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Contact
|
|
175
|
+
|
|
176
|
+
For questions or feedback, feel free to reach out:
|
|
177
|
+
|
|
178
|
+
- **Email**: ishan.kodithuwakku.offical@gmail.com
|
|
179
|
+
- **GitHub**: [ishanoshada](https://github.com/ishanoshada)
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
Enjoy decoding with **Decodify**! 🚀
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
setup.py
|
|
3
|
+
decodify/__init__.py
|
|
4
|
+
decodify/cli.py
|
|
5
|
+
decodify/decodify.py
|
|
6
|
+
decodify.egg-info/PKG-INFO
|
|
7
|
+
decodify.egg-info/SOURCES.txt
|
|
8
|
+
decodify.egg-info/dependency_links.txt
|
|
9
|
+
decodify.egg-info/entry_points.txt
|
|
10
|
+
decodify.egg-info/top_level.txt
|
|
11
|
+
decodify/algorithms/__init__.py
|
|
12
|
+
decodify/algorithms/base64.py
|
|
13
|
+
decodify/algorithms/binary.py
|
|
14
|
+
decodify/algorithms/hex.py
|
|
15
|
+
decodify/algorithms/morse.py
|
|
16
|
+
decodify/algorithms/url.py
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[egg_info]
|
|
2
|
-
tag_build =
|
|
3
|
-
tag_date = 0
|
|
4
|
-
|
|
1
|
+
[egg_info]
|
|
2
|
+
tag_build =
|
|
3
|
+
tag_date = 0
|
|
4
|
+
|
decodify-0.1.3/setup.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# setup.py
|
|
2
|
+
from setuptools import setup, find_packages
|
|
3
|
+
|
|
4
|
+
setup(
|
|
5
|
+
name='decodify',
|
|
6
|
+
version='0.1.3',
|
|
7
|
+
packages=find_packages(),
|
|
8
|
+
install_requires=[],
|
|
9
|
+
entry_points={
|
|
10
|
+
'console_scripts': [
|
|
11
|
+
'decodify=decodify.cli:main',
|
|
12
|
+
],
|
|
13
|
+
},
|
|
14
|
+
author='Ishan Oshada',
|
|
15
|
+
author_email='ishan.kodithuwakku.offical@gmail.com',
|
|
16
|
+
description='An advanced package to detect encoding algorithms and decode messages.',
|
|
17
|
+
long_description=open('README.md').read(),
|
|
18
|
+
long_description_content_type='text/markdown',
|
|
19
|
+
url='https://github.com/ishanoshada/decodify',
|
|
20
|
+
keywords=['encoding', 'decoding', 'cryptography', 'cipher', 'decode', 'encoder', 'decoder', 'base64', 'hash'],
|
|
21
|
+
classifiers=[
|
|
22
|
+
'Programming Language :: Python :: 3',
|
|
23
|
+
'Programming Language :: Python :: 3.6',
|
|
24
|
+
'Programming Language :: Python :: 3.7',
|
|
25
|
+
'Programming Language :: Python :: 3.8',
|
|
26
|
+
'Programming Language :: Python :: 3.9',
|
|
27
|
+
'License :: OSI Approved :: MIT License',
|
|
28
|
+
'Operating System :: OS Independent',
|
|
29
|
+
'Topic :: Security :: Cryptography',
|
|
30
|
+
'Topic :: Software Development :: Libraries :: Python Modules',
|
|
31
|
+
'Intended Audience :: Developers',
|
|
32
|
+
'Development Status :: 4 - Beta'
|
|
33
|
+
]
|
|
34
|
+
)
|
decodify-0.0.1/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Ishan Oshada
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
decodify-0.0.1/PKG-INFO
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: decodify
|
|
3
|
-
Version: 0.0.1
|
|
4
|
-
Summary: under development
|
|
5
|
-
Home-page: https://github.com/ishanoshada/decodify
|
|
6
|
-
Author: Ishan Oshada
|
|
7
|
-
Author-email: ishan.kodithuwakku.official@email.com
|
|
8
|
-
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
-
Classifier: Operating System :: OS Independent
|
|
11
|
-
Description-Content-Type: text/markdown
|
|
12
|
-
License-File: LICENSE
|
|
13
|
-
Requires-Dist: requests
|
|
14
|
-
|
|
15
|
-
# Package Name
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
A brief description of your package. Highlight its primary purpose and value proposition.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
*Released in 2026.*
|
decodify-0.0.1/README.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
a = 'hehe'
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: decodify
|
|
3
|
-
Version: 0.0.1
|
|
4
|
-
Summary: under development
|
|
5
|
-
Home-page: https://github.com/ishanoshada/decodify
|
|
6
|
-
Author: Ishan Oshada
|
|
7
|
-
Author-email: ishan.kodithuwakku.official@email.com
|
|
8
|
-
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
-
Classifier: Operating System :: OS Independent
|
|
11
|
-
Description-Content-Type: text/markdown
|
|
12
|
-
License-File: LICENSE
|
|
13
|
-
Requires-Dist: requests
|
|
14
|
-
|
|
15
|
-
# Package Name
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
A brief description of your package. Highlight its primary purpose and value proposition.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
*Released in 2026.*
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
requests
|
decodify-0.0.1/setup.py
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
from setuptools import setup, find_packages
|
|
2
|
-
|
|
3
|
-
setup(
|
|
4
|
-
name='decodify',
|
|
5
|
-
version='0.0.1',
|
|
6
|
-
packages=find_packages(),
|
|
7
|
-
install_requires=['requests'],
|
|
8
|
-
author='Ishan Oshada',
|
|
9
|
-
author_email='ishan.kodithuwakku.official@email.com',
|
|
10
|
-
long_description=open('README.md').read(),
|
|
11
|
-
long_description_content_type='text/markdown',
|
|
12
|
-
description='under development',
|
|
13
|
-
url='https://github.com/ishanoshada/decodify',
|
|
14
|
-
classifiers=[
|
|
15
|
-
'Programming Language :: Python :: 3',
|
|
16
|
-
'License :: OSI Approved :: MIT License',
|
|
17
|
-
'Operating System :: OS Independent',
|
|
18
|
-
],
|
|
19
|
-
)
|
|
File without changes
|
|
File without changes
|