Skip to content

Commit 447aace

Browse files
authored
Update README.md
1 parent 7443d33 commit 447aace

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

README.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,46 @@ In this repository I have implemented two simple function just do that, which ta
4545

4646
Samewise to decryption, you are going to specify the secret number and then it will recieve your encrypted text input and then render to you decrypted text output
4747

48+
# ASCII-based Encryption/Decryption
49+
50+
This Python script provides simple ASCII-based encryption and decryption functionalities. The code has been improved to enhance key handling, error checking, and overall robustness.
51+
52+
## Improvements
53+
54+
### Key Handling
55+
- The `key` parameter now accepts both strings and bytes, providing more flexibility for different types of keys.
56+
- The key is automatically encoded if it is provided as a string.
57+
58+
### Non-ASCII Characters
59+
- The script now handles non-ASCII characters more gracefully.
60+
61+
### Error Handling
62+
- Error checks have been added to ensure that both the text and the key are not empty.
63+
64+
### Modulo Operation
65+
- A modulo operation has been introduced to prevent overflow issues during character shifting. This ensures that the character values stay within the valid ASCII range.
66+
67+
## Usage
68+
69+
```python
70+
from itertools import cycle
71+
72+
def encrypt(text, key='0'):
73+
# ... (implementation details)
74+
75+
def decrypt(text, key='0'):
76+
# ... (implementation details)
77+
78+
# Example Usage:
79+
original_message = "Hello, World!"
80+
encryption_key = "secretkey"
81+
82+
encrypted_message = encrypt(original_message, encryption_key)
83+
print(f"Encrypted: {encrypted_message}")
84+
85+
decrypted_message = decrypt(encrypted_message, encryption_key)
86+
print(f"Decrypted: {decrypted_message}")
87+
4888

4989
Demo
5090
------------
@@ -69,4 +109,4 @@ Did you find this information useful, then give it a star
69109

70110
Credits
71111
-----------
72-
All the credits to [kalebu](github.com/kalebu)
112+
All the credits to [kalebu](github.com/kalebu)

0 commit comments

Comments
 (0)