Skip to content

Commit 526d7dd

Browse files
Merge branch 'Aakash02A:main' into main
2 parents 1b0e77f + 44f10cd commit 526d7dd

File tree

5 files changed

+30
-0
lines changed

5 files changed

+30
-0
lines changed

caesar_cipher/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ The script:
9292
chr((ord(char) - base + shift) % 26 + base)
9393
```
9494

95+
9596
* `ord(char)` – ASCII of char
9697
* `base``ord('a')` or `ord('A')`
9798
* `shift` – Provided shift value

image_encryption_tool/decry.jpg

28.9 KB
Loading

image_encryption_tool/encry.jpg

28.9 KB
Loading
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
def xor_encrypt_decrypt(input_path, output_path, key):
2+
try:
3+
with open(input_path, 'rb') as f:
4+
data = bytearray(f.read()) # Read image as byte array
5+
6+
for i in range(len(data)):
7+
data[i] ^= key # XOR each byte with key
8+
9+
with open(output_path, 'wb') as f:
10+
f.write(data)
11+
12+
print(f"[+] Process completed. Output saved to: {output_path}")
13+
except FileNotFoundError:
14+
print("[-] File not found. Please check the path.")
15+
except Exception as e:
16+
print(f"[-] Error: {str(e)}")
17+
18+
# Example usage
19+
if __name__ == "__main__":
20+
print("Image Encryption/Decryption Tool")
21+
input_file = input("Enter image path: ")
22+
output_file = input("Enter output file path: ")
23+
key = int(input("Enter a secret key (0-255): "))
24+
25+
if 0 <= key <= 255:
26+
xor_encrypt_decrypt(input_file, output_file, key)
27+
else:
28+
print("[-] Key must be between 0 and 255.")
29+

image_encryption_tool/oggy.jpeg

28.9 KB
Loading

0 commit comments

Comments
 (0)