Skip to content

Commit f367068

Browse files
committed
fail fix
1 parent 5c2b560 commit f367068

5 files changed

Lines changed: 72 additions & 2 deletions

File tree

.github/workflows/python-app.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
matrix:
1818
# Run in all these versions of Python
19-
python-version: [3.7, 3.8, 3.9]
19+
python-version: [3.7, 3.9]
2020

2121
steps:
2222
# Checkout the latest code from the repo

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ __pycache__/
22
piencrypt.egg-info/
33
web/data.py
44
piencrypt/__pycache__/
5-
build/
65
Helper/
76
Test/__pycache__/
87
Test/data.py

build/lib/piencrypt/__init__.py

Whitespace-only changes.

build/lib/piencrypt/pie.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
pie_hash = '03c1d04aeffd72151933b2295df5b484547e00ead9d001126aef03e6179a9332'
2+
3+
class PiEncrypt:
4+
5+
def __init__(self, loc):
6+
self.loc = loc
7+
8+
# save the data of the picture as bytes
9+
def get_data(self):
10+
with open(self.loc , 'rb') as f, open('binary.txt', 'wb') as b:
11+
r = f.read()
12+
b.write(r)
13+
14+
# hides the disired data into the picture
15+
def hide_data(self, data):
16+
self.data = data
17+
with open(self.loc, 'ab') as f:
18+
f.write(bytes(pie_hash + self.data , encoding="ascii"))
19+
20+
# read the hidden data from the picture
21+
def read_data(self):
22+
with open(self.loc, 'rb') as f:
23+
content = f.read()
24+
list = content.split(bytes(pie_hash, encoding="ascii"))
25+
# print(f.read())
26+
return list[1].decode("utf-8")
27+
28+
# revert the picture from the backup bytes file
29+
def revert(self):
30+
with open('binary.txt', 'rb') as f, open(self.loc, 'wb') as e:
31+
r = f.read()
32+
e.write(r)
33+
34+
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")
40+
r = p.read_data()
41+
print(r)

build/lib/piencrypt/piencrypt.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# save the data of the picture as bytes
2+
def get_data(loc):
3+
with open(loc , 'rb') as f, open('binary.txt', 'wb') as b:
4+
r = f.read()
5+
b.write(r)
6+
# hides the disired data into the picture
7+
def hide_data(loc, data):
8+
with open(loc, 'ab') as f:
9+
f.write(bytes("HERE" + data , encoding="ascii"))
10+
# read the hidden data from the picture
11+
def read_data(loc):
12+
with open(loc, 'rb') as f:
13+
content = f.read()
14+
list = content.split(b'HERE')
15+
# print(f.read())
16+
return list[1].decode("utf-8")
17+
# revert the picture from the backup bytes file
18+
def revert(loc):
19+
with open('binary.txt', 'rb') as f, open(loc, 'wb') as e:
20+
r = f.read()
21+
e.write(r)
22+
23+
24+
if __name__ == '__main__':
25+
get_data('img.PNG')
26+
# p.revert()
27+
# p.hide_data("Hello my name is Sid")
28+
# r = p.read_data()
29+
# print(r)
30+

0 commit comments

Comments
 (0)