rot-converter 0.1.0__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.
- rot_converter-0.1.0/LICENSE +19 -0
- rot_converter-0.1.0/PKG-INFO +132 -0
- rot_converter-0.1.0/README.md +104 -0
- rot_converter-0.1.0/pyproject.toml +38 -0
- rot_converter-0.1.0/rot_converter/__init__.py +15 -0
- rot_converter-0.1.0/rot_converter/converter.py +96 -0
- rot_converter-0.1.0/rot_converter.egg-info/PKG-INFO +132 -0
- rot_converter-0.1.0/rot_converter.egg-info/SOURCES.txt +10 -0
- rot_converter-0.1.0/rot_converter.egg-info/dependency_links.txt +1 -0
- rot_converter-0.1.0/rot_converter.egg-info/top_level.txt +1 -0
- rot_converter-0.1.0/setup.cfg +4 -0
- rot_converter-0.1.0/tests/test_converter.py +59 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2018 The Python Packaging Authority
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rot-converter
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A library for the ROT cipher.
|
|
5
|
+
Author-email: BasicSweater <ivanvotints@yandex.ru>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/BasicTShirt/rot-converter/blob/main/README.md
|
|
8
|
+
Project-URL: Repository, https://github.com/BasicTShirt/rot-converter
|
|
9
|
+
Keywords: rot,converter,beta
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Requires-Python: >=3.6
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# First Version: 0.1.0!
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
# ROT Converter
|
|
34
|
+
|
|
35
|
+
A library for the ROT cipher.
|
|
36
|
+
|
|
37
|
+
## Features
|
|
38
|
+
|
|
39
|
+
- Encryption and decryption from ROT.
|
|
40
|
+
- ROT bruteforce.
|
|
41
|
+
- Error handling with clear messages.
|
|
42
|
+
|
|
43
|
+
## Installation
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install rot-converter
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Usage
|
|
52
|
+
|
|
53
|
+
- To import, use «from rot_converter import *» or «from rot_converter import m_rot, b_rot».
|
|
54
|
+
- To use the library functions, use the command «m_rot(string: str, key: int)» or «b_rot(string: str)».
|
|
55
|
+
|
|
56
|
+
### For example
|
|
57
|
+
|
|
58
|
+
#### This program accepts a string (str) as input and outputs this string in the ROT.
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from rot import m_rot
|
|
62
|
+
|
|
63
|
+
temp_str = input() # Input: tqv_eqpxgtvgt
|
|
64
|
+
new_str = m_rot(temp_str, 2)
|
|
65
|
+
|
|
66
|
+
print(new_str) # Output: rot_converter
|
|
67
|
+
```
|
|
68
|
+
## Requirements
|
|
69
|
+
|
|
70
|
+
- Python 3.6 or higher.
|
|
71
|
+
- No external dependencies (uses only standard library).
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Error Handling
|
|
76
|
+
|
|
77
|
+
The library includes a comprehensive error handling system that validates inputs and provides clear, informative error messages.
|
|
78
|
+
|
|
79
|
+
### Error Types
|
|
80
|
+
| Error | Description |
|
|
81
|
+
|----------------------------------|--------------------------------------------------------------------------------------|
|
|
82
|
+
| **You did not enter a string** | The ROT_string parameter is missing or passed as an empty string "" |
|
|
83
|
+
| **Key is not an integer** | The ROT_key parameter cannot be a floating-point number, string, or any non-int type |
|
|
84
|
+
| **You did not enter a key** | The ROT_key parameter is required but missing (None) in manual mode |
|
|
85
|
+
### Error Examples
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from rot import m_rot, b_rot
|
|
89
|
+
|
|
90
|
+
# Missing string
|
|
91
|
+
result = m_rot("", 24)
|
|
92
|
+
print(result)
|
|
93
|
+
# Output:
|
|
94
|
+
# ERROR! You did not enter a string
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
# Missing key in manual mode
|
|
98
|
+
result = m_rot("tqv_eqpxgtvgt", None)
|
|
99
|
+
print(result)
|
|
100
|
+
# Output:
|
|
101
|
+
# ERROR! You did not enter a key
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
# Key is a float number
|
|
105
|
+
result = m_rot("tqv_eqpxgtvgt", 1.5)
|
|
106
|
+
print(result)
|
|
107
|
+
# Output:
|
|
108
|
+
# ERROR! Type of the key is not a integer
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
# Key is a string
|
|
112
|
+
result = m_rot("tqv_eqpxgtvgt", "key")
|
|
113
|
+
print(result)
|
|
114
|
+
# Output:
|
|
115
|
+
# ERROR! Type of the key is not a integer
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
# Multiple errors (all displayed)
|
|
119
|
+
result = m_rot("", 2.5)
|
|
120
|
+
print(result)
|
|
121
|
+
# Output:
|
|
122
|
+
# ERROR! You did not enter a string
|
|
123
|
+
# ERROR! Type of the key is not a integer
|
|
124
|
+
```
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Changelog
|
|
128
|
+
|
|
129
|
+
| Version | Date | Commit |
|
|
130
|
+
|-----------|------------|-----------------------------------------------------------------------------------------------------------|
|
|
131
|
+
| **0.1.0** | 07.08.2026 | Beta: First Beta Version On PyPI |
|
|
132
|
+
###### **Made by the Hi Team.**
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# First Version: 0.1.0!
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# ROT Converter
|
|
6
|
+
|
|
7
|
+
A library for the ROT cipher.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- Encryption and decryption from ROT.
|
|
12
|
+
- ROT bruteforce.
|
|
13
|
+
- Error handling with clear messages.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install rot-converter
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
- To import, use «from rot_converter import *» or «from rot_converter import m_rot, b_rot».
|
|
26
|
+
- To use the library functions, use the command «m_rot(string: str, key: int)» or «b_rot(string: str)».
|
|
27
|
+
|
|
28
|
+
### For example
|
|
29
|
+
|
|
30
|
+
#### This program accepts a string (str) as input and outputs this string in the ROT.
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from rot import m_rot
|
|
34
|
+
|
|
35
|
+
temp_str = input() # Input: tqv_eqpxgtvgt
|
|
36
|
+
new_str = m_rot(temp_str, 2)
|
|
37
|
+
|
|
38
|
+
print(new_str) # Output: rot_converter
|
|
39
|
+
```
|
|
40
|
+
## Requirements
|
|
41
|
+
|
|
42
|
+
- Python 3.6 or higher.
|
|
43
|
+
- No external dependencies (uses only standard library).
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Error Handling
|
|
48
|
+
|
|
49
|
+
The library includes a comprehensive error handling system that validates inputs and provides clear, informative error messages.
|
|
50
|
+
|
|
51
|
+
### Error Types
|
|
52
|
+
| Error | Description |
|
|
53
|
+
|----------------------------------|--------------------------------------------------------------------------------------|
|
|
54
|
+
| **You did not enter a string** | The ROT_string parameter is missing or passed as an empty string "" |
|
|
55
|
+
| **Key is not an integer** | The ROT_key parameter cannot be a floating-point number, string, or any non-int type |
|
|
56
|
+
| **You did not enter a key** | The ROT_key parameter is required but missing (None) in manual mode |
|
|
57
|
+
### Error Examples
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from rot import m_rot, b_rot
|
|
61
|
+
|
|
62
|
+
# Missing string
|
|
63
|
+
result = m_rot("", 24)
|
|
64
|
+
print(result)
|
|
65
|
+
# Output:
|
|
66
|
+
# ERROR! You did not enter a string
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
# Missing key in manual mode
|
|
70
|
+
result = m_rot("tqv_eqpxgtvgt", None)
|
|
71
|
+
print(result)
|
|
72
|
+
# Output:
|
|
73
|
+
# ERROR! You did not enter a key
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
# Key is a float number
|
|
77
|
+
result = m_rot("tqv_eqpxgtvgt", 1.5)
|
|
78
|
+
print(result)
|
|
79
|
+
# Output:
|
|
80
|
+
# ERROR! Type of the key is not a integer
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
# Key is a string
|
|
84
|
+
result = m_rot("tqv_eqpxgtvgt", "key")
|
|
85
|
+
print(result)
|
|
86
|
+
# Output:
|
|
87
|
+
# ERROR! Type of the key is not a integer
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
# Multiple errors (all displayed)
|
|
91
|
+
result = m_rot("", 2.5)
|
|
92
|
+
print(result)
|
|
93
|
+
# Output:
|
|
94
|
+
# ERROR! You did not enter a string
|
|
95
|
+
# ERROR! Type of the key is not a integer
|
|
96
|
+
```
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Changelog
|
|
100
|
+
|
|
101
|
+
| Version | Date | Commit |
|
|
102
|
+
|-----------|------------|-----------------------------------------------------------------------------------------------------------|
|
|
103
|
+
| **0.1.0** | 07.08.2026 | Beta: First Beta Version On PyPI |
|
|
104
|
+
###### **Made by the Hi Team.**
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "rot-converter"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
authors = [
|
|
9
|
+
{name = "BasicSweater", email = "ivanvotints@yandex.ru"},
|
|
10
|
+
]
|
|
11
|
+
description = "A library for the ROT cipher."
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
requires-python = ">=3.6"
|
|
14
|
+
license = {text = "MIT"}
|
|
15
|
+
keywords = ["rot", "converter", "beta"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 5 - Production/Stable",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"License :: OSI Approved :: MIT License",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.6",
|
|
22
|
+
"Programming Language :: Python :: 3.7",
|
|
23
|
+
"Programming Language :: Python :: 3.8",
|
|
24
|
+
"Programming Language :: Python :: 3.9",
|
|
25
|
+
"Programming Language :: Python :: 3.10",
|
|
26
|
+
"Programming Language :: Python :: 3.11",
|
|
27
|
+
"Programming Language :: Python :: 3.12",
|
|
28
|
+
"Programming Language :: Python :: 3.13",
|
|
29
|
+
"Programming Language :: Python :: 3.14",
|
|
30
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.urls]
|
|
34
|
+
Homepage = "https://github.com/BasicTShirt/rot-converter/blob/main/README.md"
|
|
35
|
+
Repository = "https://github.com/BasicTShirt/rot-converter"
|
|
36
|
+
|
|
37
|
+
[tool.setuptools]
|
|
38
|
+
packages = ["rot_converter"]
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Sys Converter - a library for converting numbers between different number systems.
|
|
3
|
+
|
|
4
|
+
Main features:
|
|
5
|
+
- Convert integers to any number system (2-36)
|
|
6
|
+
- Convert fractional numbers with precision limit
|
|
7
|
+
- Error handling and input validation
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
__version__ = "0.1.0"
|
|
11
|
+
__author__ = "BasicSweater"
|
|
12
|
+
|
|
13
|
+
from .converter import m_rot, b_rot
|
|
14
|
+
|
|
15
|
+
__all__ = ["m_rot", "b_rot"]
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -
|
|
3
|
+
# version 0.1.0
|
|
4
|
+
|
|
5
|
+
class ROT_Convertor_Class():
|
|
6
|
+
def __init__(self):
|
|
7
|
+
super().__init__()
|
|
8
|
+
|
|
9
|
+
self.alphabet = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
|
|
10
|
+
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
|
|
11
|
+
'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
|
|
12
|
+
|
|
13
|
+
def combine_error_handler(self, ROT_string, ROT_key):
|
|
14
|
+
self.error_state = None
|
|
15
|
+
self.error_message = None
|
|
16
|
+
|
|
17
|
+
self.errors = []
|
|
18
|
+
|
|
19
|
+
self.type_ROT_string = type(ROT_string)
|
|
20
|
+
self.type_ROT_key = type(ROT_key)
|
|
21
|
+
|
|
22
|
+
if ROT_string is None or ROT_string == "":
|
|
23
|
+
self.errors.append("ERROR! You did not enter a string")
|
|
24
|
+
|
|
25
|
+
if self.mode == "manual":
|
|
26
|
+
if ROT_key is None:
|
|
27
|
+
self.errors.append("ERROR! You did not enter a key")
|
|
28
|
+
else:
|
|
29
|
+
if self.type_ROT_key != int:
|
|
30
|
+
self.errors.append("ERROR! Type of the key is not a integer")
|
|
31
|
+
|
|
32
|
+
if self.errors:
|
|
33
|
+
self.error_state = False
|
|
34
|
+
self.error_message = "\n".join(self.errors) + "\n"
|
|
35
|
+
else:
|
|
36
|
+
self.error_state = True
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def m_rot(self, ROT_string, ROT_key):
|
|
40
|
+
self.mode = "manual"
|
|
41
|
+
self.local_ROT_string = str(ROT_string)
|
|
42
|
+
self.local_ROT_key = ROT_key
|
|
43
|
+
|
|
44
|
+
self.combine_error_handler(ROT_string, ROT_key)
|
|
45
|
+
|
|
46
|
+
if self.error_state:
|
|
47
|
+
self.new_ROT_string = ""
|
|
48
|
+
|
|
49
|
+
for self.symbol in self.local_ROT_string:
|
|
50
|
+
if self.symbol.upper() in self.alphabet:
|
|
51
|
+
if self.symbol.islower():
|
|
52
|
+
self.new_ROT_string += chr((ord(self.symbol) - ord("a") - self.local_ROT_key) % 26 + ord("a"))
|
|
53
|
+
else:
|
|
54
|
+
self.new_ROT_string += chr((ord(self.symbol) - ord("A") - self.local_ROT_key) % 26 + ord("A"))
|
|
55
|
+
else:
|
|
56
|
+
self.new_ROT_string += self.symbol
|
|
57
|
+
|
|
58
|
+
return self.new_ROT_string
|
|
59
|
+
else:
|
|
60
|
+
return self.error_message
|
|
61
|
+
|
|
62
|
+
def b_rot(self, ROT_string):
|
|
63
|
+
self.mode = "bruteforce"
|
|
64
|
+
self.local_ROT_string = str(ROT_string)
|
|
65
|
+
|
|
66
|
+
self.combine_error_handler(ROT_string, None)
|
|
67
|
+
|
|
68
|
+
if self.error_state:
|
|
69
|
+
self.new_ROT_string = ""
|
|
70
|
+
self.bruteforce_list = []
|
|
71
|
+
|
|
72
|
+
for self.bruteforce_key in range(1, 26):
|
|
73
|
+
for self.symbol in self.local_ROT_string:
|
|
74
|
+
if self.symbol.upper() in self.alphabet:
|
|
75
|
+
if self.symbol.islower():
|
|
76
|
+
self.new_ROT_string += chr((ord(self.symbol) - ord("a") - self.bruteforce_key) % 26 + ord("a"))
|
|
77
|
+
else:
|
|
78
|
+
self.new_ROT_string += chr((ord(self.symbol) - ord("A") - self.bruteforce_key) % 26 + ord("A"))
|
|
79
|
+
else:
|
|
80
|
+
self.new_ROT_string += self.symbol
|
|
81
|
+
self.bruteforce_list.append(self.new_ROT_string)
|
|
82
|
+
self.new_ROT_string = ""
|
|
83
|
+
return self.bruteforce_list[::-1]
|
|
84
|
+
else:
|
|
85
|
+
return self.error_message
|
|
86
|
+
|
|
87
|
+
M = ROT_Convertor_Class()
|
|
88
|
+
|
|
89
|
+
def m_rot(s, n):
|
|
90
|
+
return M.m_rot(s, n)
|
|
91
|
+
def b_rot(s):
|
|
92
|
+
return M.b_rot(s)
|
|
93
|
+
|
|
94
|
+
if __name__ == '__main__':
|
|
95
|
+
m_rot(s, n)
|
|
96
|
+
b_rot(s)
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rot-converter
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A library for the ROT cipher.
|
|
5
|
+
Author-email: BasicSweater <ivanvotints@yandex.ru>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/BasicTShirt/rot-converter/blob/main/README.md
|
|
8
|
+
Project-URL: Repository, https://github.com/BasicTShirt/rot-converter
|
|
9
|
+
Keywords: rot,converter,beta
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Requires-Python: >=3.6
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# First Version: 0.1.0!
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
# ROT Converter
|
|
34
|
+
|
|
35
|
+
A library for the ROT cipher.
|
|
36
|
+
|
|
37
|
+
## Features
|
|
38
|
+
|
|
39
|
+
- Encryption and decryption from ROT.
|
|
40
|
+
- ROT bruteforce.
|
|
41
|
+
- Error handling with clear messages.
|
|
42
|
+
|
|
43
|
+
## Installation
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install rot-converter
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Usage
|
|
52
|
+
|
|
53
|
+
- To import, use «from rot_converter import *» or «from rot_converter import m_rot, b_rot».
|
|
54
|
+
- To use the library functions, use the command «m_rot(string: str, key: int)» or «b_rot(string: str)».
|
|
55
|
+
|
|
56
|
+
### For example
|
|
57
|
+
|
|
58
|
+
#### This program accepts a string (str) as input and outputs this string in the ROT.
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from rot import m_rot
|
|
62
|
+
|
|
63
|
+
temp_str = input() # Input: tqv_eqpxgtvgt
|
|
64
|
+
new_str = m_rot(temp_str, 2)
|
|
65
|
+
|
|
66
|
+
print(new_str) # Output: rot_converter
|
|
67
|
+
```
|
|
68
|
+
## Requirements
|
|
69
|
+
|
|
70
|
+
- Python 3.6 or higher.
|
|
71
|
+
- No external dependencies (uses only standard library).
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Error Handling
|
|
76
|
+
|
|
77
|
+
The library includes a comprehensive error handling system that validates inputs and provides clear, informative error messages.
|
|
78
|
+
|
|
79
|
+
### Error Types
|
|
80
|
+
| Error | Description |
|
|
81
|
+
|----------------------------------|--------------------------------------------------------------------------------------|
|
|
82
|
+
| **You did not enter a string** | The ROT_string parameter is missing or passed as an empty string "" |
|
|
83
|
+
| **Key is not an integer** | The ROT_key parameter cannot be a floating-point number, string, or any non-int type |
|
|
84
|
+
| **You did not enter a key** | The ROT_key parameter is required but missing (None) in manual mode |
|
|
85
|
+
### Error Examples
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from rot import m_rot, b_rot
|
|
89
|
+
|
|
90
|
+
# Missing string
|
|
91
|
+
result = m_rot("", 24)
|
|
92
|
+
print(result)
|
|
93
|
+
# Output:
|
|
94
|
+
# ERROR! You did not enter a string
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
# Missing key in manual mode
|
|
98
|
+
result = m_rot("tqv_eqpxgtvgt", None)
|
|
99
|
+
print(result)
|
|
100
|
+
# Output:
|
|
101
|
+
# ERROR! You did not enter a key
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
# Key is a float number
|
|
105
|
+
result = m_rot("tqv_eqpxgtvgt", 1.5)
|
|
106
|
+
print(result)
|
|
107
|
+
# Output:
|
|
108
|
+
# ERROR! Type of the key is not a integer
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
# Key is a string
|
|
112
|
+
result = m_rot("tqv_eqpxgtvgt", "key")
|
|
113
|
+
print(result)
|
|
114
|
+
# Output:
|
|
115
|
+
# ERROR! Type of the key is not a integer
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
# Multiple errors (all displayed)
|
|
119
|
+
result = m_rot("", 2.5)
|
|
120
|
+
print(result)
|
|
121
|
+
# Output:
|
|
122
|
+
# ERROR! You did not enter a string
|
|
123
|
+
# ERROR! Type of the key is not a integer
|
|
124
|
+
```
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Changelog
|
|
128
|
+
|
|
129
|
+
| Version | Date | Commit |
|
|
130
|
+
|-----------|------------|-----------------------------------------------------------------------------------------------------------|
|
|
131
|
+
| **0.1.0** | 07.08.2026 | Beta: First Beta Version On PyPI |
|
|
132
|
+
###### **Made by the Hi Team.**
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
rot_converter/__init__.py
|
|
5
|
+
rot_converter/converter.py
|
|
6
|
+
rot_converter.egg-info/PKG-INFO
|
|
7
|
+
rot_converter.egg-info/SOURCES.txt
|
|
8
|
+
rot_converter.egg-info/dependency_links.txt
|
|
9
|
+
rot_converter.egg-info/top_level.txt
|
|
10
|
+
tests/test_converter.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
rot_converter
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Tests for the rot module
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import unittest
|
|
6
|
+
import sys
|
|
7
|
+
import os
|
|
8
|
+
|
|
9
|
+
# Добавляем родительскую директорию в путь, чтобы импортировать модуль rot
|
|
10
|
+
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
|
11
|
+
|
|
12
|
+
from rot import m_rot, b_rot
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class TestROTConverter(unittest.TestCase):
|
|
16
|
+
"""Tests for the ROT cipher and bruteforce functions"""
|
|
17
|
+
|
|
18
|
+
def test_manual_rot_decryption(self):
|
|
19
|
+
"""Test encryption/decryption with specific keys"""
|
|
20
|
+
# Сдвиг назад на 24 (эквивалентно сдвигу вперед на 2 для строки 'rot_converter')
|
|
21
|
+
self.assertEqual(m_rot("tqv_eqpxgtvgt", 24), "rot_converter")
|
|
22
|
+
# Сохранение регистра символов
|
|
23
|
+
self.assertEqual(m_rot("TQV_eqpxgtvgt", 24), "ROT_converter")
|
|
24
|
+
# Проверка полного цикла алфавита (сдвиг 26 возвращает ту же строку)
|
|
25
|
+
self.assertEqual(m_rot("Hello_World", 26), "Hello_World")
|
|
26
|
+
|
|
27
|
+
def test_bruteforce_rot(self):
|
|
28
|
+
"""Test bruteforce decryption"""
|
|
29
|
+
results = b_rot("tqv")
|
|
30
|
+
# b_rot возвращает инвертированный список из 25 вариантов (от ключа 25 до 1)
|
|
31
|
+
self.assertIsInstance(results, list)
|
|
32
|
+
self.assertEqual(len(results), 25)
|
|
33
|
+
# Так как список перевернут ([::-1]), ключ 24 будет вторым с конца (индекс -2)
|
|
34
|
+
# tqv со сдвигом 24 -> rot
|
|
35
|
+
self.assertEqual(results[-2], "rot")
|
|
36
|
+
|
|
37
|
+
def test_error_handling(self):
|
|
38
|
+
"""Test validation and error handling messages"""
|
|
39
|
+
self.assertIn("You did not enter a string", m_rot("", 24))
|
|
40
|
+
self.assertIn("You did not enter a key", m_rot("tqv_eqpxgtvgt", None))
|
|
41
|
+
self.assertIn("Type of the key is not a integer", m_rot("tqv_eqpxgtvgt", 1.5))
|
|
42
|
+
self.assertIn("Type of the key is not a integer", m_rot("tqv_eqpxgtvgt", "key"))
|
|
43
|
+
|
|
44
|
+
def test_multiple_errors(self):
|
|
45
|
+
"""Test displaying multiple error messages at once"""
|
|
46
|
+
error_output = m_rot("", 1.5)
|
|
47
|
+
self.assertIn("You did not enter a string", error_output)
|
|
48
|
+
self.assertIn("Type of the key is not a integer", error_output)
|
|
49
|
+
|
|
50
|
+
def test_edge_cases(self):
|
|
51
|
+
"""Test edge cases like numbers, spaces, and punctuation symbols"""
|
|
52
|
+
# Символы, которых нет в латинском алфавите, должны оставаться неизменными
|
|
53
|
+
self.assertEqual(m_rot("12345!@# ", 10), "12345!@# ")
|
|
54
|
+
# Сдвиг 0 не должен изменять строку
|
|
55
|
+
self.assertEqual(m_rot("NoChange", 0), "NoChange")
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
if __name__ == '__main__':
|
|
59
|
+
unittest.main()
|