Skip to content

Commit 44f10cd

Browse files
committed
finished code work
1 parent dde979a commit 44f10cd

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

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)