Skip to content

Commit 460e7eb

Browse files
committed
Symmetric encryption
1 parent 881e2c5 commit 460e7eb

File tree

5 files changed

+25
-11
lines changed

5 files changed

+25
-11
lines changed

Script/git_push.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ echo "piencrypt: -----> Tracking files..";
1616
echo -en '\n';
1717
git add .;
1818
echo -en '\n';
19-
git commit -m "web bugfix";
19+
git commit -m "Symmetric encryption";
2020
echo -en '\n';
2121
echo "piencrypt: -----> Commit completed";
2222
echo -en '\n';
15.5 KB
Binary file not shown.

dist/piencrypt-0.7.5.6.tar.gz

14.7 KB
Binary file not shown.

piencrypt/pie.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
2+
from cryptography.fernet import Fernet
13
pie_hash = '03c1d04aeffd72151933b2295df5b484547e00ead9d001126aef03e6179a9332'
24

5+
key = b'2PlCwYo0bGpbWBQ6onpmmKv9T8lshcJhI7R00NKxKpM='
6+
clipher = Fernet(key)
7+
38
class PiEncrypt:
49

510
def __init__(self, loc):
@@ -14,16 +19,23 @@ def get_data(self):
1419
# hides the disired data into the picture
1520
def hide_data(self, data):
1621
self.data = data
22+
# encrypt the data
23+
encrypt_text = clipher.encrypt(bytes(pie_hash + self.data, encoding="ascii"))
24+
# save to the image
1725
with open(self.loc, 'ab') as f:
18-
f.write(bytes(pie_hash + self.data , encoding="ascii"))
26+
f.write(bytes(pie_hash, encoding="ascii") + encrypt_text)
1927

2028
# read the hidden data from the picture
2129
def read_data(self):
2230
with open(self.loc, 'rb') as f:
2331
content = f.read()
2432
list = content.split(bytes(pie_hash, encoding="ascii"))
25-
# print(f.read())
26-
return list[1].decode("utf-8")
33+
data = list[1]
34+
# dencrypt the text
35+
dencrypt_text = clipher.decrypt(data).decode("utf-8")
36+
# seperate by pie_hash
37+
output = dencrypt_text.split(pie_hash)
38+
return output[1]
2739

2840
# revert the picture from the backup bytes file
2941
def revert(self):
@@ -32,10 +44,12 @@ def revert(self):
3244
e.write(r)
3345

3446
if __name__ == '__main__':
35-
36-
p = PiEncrypt('test.png')
37-
# p.get_data()
38-
p.revert()
39-
p.hide_data("Hello my name is Sid")
47+
# print(key)
48+
# print(encrypt_text)
49+
# print(dencrypt_text)
50+
p = PiEncrypt('pic.png')
51+
p.get_data()
52+
p.hide_data("Hello this is piencrypt test")
4053
r = p.read_data()
54+
p.revert()
4155
print(r)

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
with codecs.open(os.path.join(here, "README.md"), encoding="utf-8") as fh:
88
long_description = "\n" + fh.read()
99

10-
VERSION = '0.7.3.8'
10+
VERSION = '0.7.5.6'
1111
DESCRIPTION = 'Encrypt your crucial data into Image file'
1212
LONG_DESCRIPTION = 'A package that allows to hide and read crucial data from Image files.'
1313

@@ -21,7 +21,7 @@
2121
long_description_content_type="text/markdown",
2222
long_description=long_description,
2323
packages=find_packages(),
24-
install_requires=[],
24+
install_requires=['cryptography'],
2525
keywords=['python', 'image processing', 'encrypt',
2626
'decrypt', 'hide messages', 'data store'],
2727
classifiers=[

0 commit comments

Comments
 (0)