-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEncryDecry.py
More file actions
32 lines (25 loc) · 787 Bytes
/
EncryDecry.py
File metadata and controls
32 lines (25 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import io
from PIL import Image
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
def encr_decry(Cipher,key):
arr = [ 0 for i in range(0, len(Cipher))]
for i in range(0, len(Cipher)):
arr[i] = Cipher[i]^key
return arr
#path = input("Enter the path of the image for encryption : ")
key = input( "Enter they key for the encryption : ")
key = int(key)
path = 'image.jpg'
with open(path, "rb") as image:
f = image.read()
imagByt = bytearray(f)
encryImage = encr_decry(imagByt,key)
encryImage = bytearray(encryImage)
print('The image has been encrypted.')
#print(encryImage)
print("Decryption process begins... ")
decryImage = encr_decry(encryImage,key)
print('The image has been decrypted.')
#print(decryImage)