Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/devskim-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ name: DevSkim

on:
push:
branches: [ master ]
branches: [ master, develop ]
pull_request:
branches: [ master ]
branches: [ master, develop ]
schedule:
- cron: '45 18 * * 5'

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name: Pie Test

on:
push:
branches: [ master ]
branches: [ master, develop ]
pull_request:
branches: [ master ]
branches: [ master, develop ]

jobs:
test:
Expand Down
10 changes: 6 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
__pycache__/
piencrypt.egg-info/
# piencrypt.egg-info/
web/data.py
piencrypt/__pycache__/
Helper/
# Helper/
Test/__pycache__/
Test/data.py
build/
Script/test.sh
# build/
Script/test.sh
# web/
.pytest_cache/
2 changes: 1 addition & 1 deletion Example/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

r.get_data()

r.hide_data("Hello my name Sid")
r.hide_data("Hello my name sid")

read = r.read_data()
print(read)
Expand Down
Binary file added Helper/requirements.txt
Binary file not shown.
5 changes: 5 additions & 0 deletions Helper/steps.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build setup : python setup.py sdist bdist_wheel

upload : twine upload dist/*

untrack files : git rm --cached piencrypt -r
60 changes: 30 additions & 30 deletions Script/build.sh
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
#build package and push it to pypi
SECONDS=0
# declare initial seconds
clear
cd ..
echo "piencrypt: -----> Starting Pie Test..";
echo -en '\n';
pip install --upgrade piencrypt;
echo -en '\n';
cd Test
python pie_test.py;
echo -en '\n';
echo "piencrypt: -----> Test completed"
echo -en '\n';
cd ..
echo "piencrypt: -----> Starting package build...";
echo -en '\n';
python setup.py sdist bdist_wheel;
echo -en '\n';
echo "piencrypt: -----> Build successfull"
echo -en '\n';
twine upload dist/*
echo -en '\n';
echo "..";
echo '----------------------------------------------------------------------';
echo "piencrypt: -----> Upload Successfull";
echo -en '\n';
# get elapsed time
duration=$SECONDS
echo "$(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
#build package and push it to pypi
SECONDS=0
# declare initial seconds
clear
cd ..
echo "piencrypt: -----> Starting Pie Test..";
echo -en '\n';
pip install --upgrade piencrypt;
echo -en '\n';
cd Test
python pie_test.py;
echo -en '\n';
echo "piencrypt: -----> Test completed"
echo -en '\n';
cd ..
echo "piencrypt: -----> Starting package build...";
echo -en '\n';
python setup.py sdist bdist_wheel;
echo -en '\n';
echo "piencrypt: -----> Build successfull"
echo -en '\n';
twine upload dist/*
echo -en '\n';
echo "..";
echo '----------------------------------------------------------------------';
echo "piencrypt: -----> Upload Successfull";
echo -en '\n';
# get elapsed time
duration=$SECONDS
echo "$(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
# cat build.sh
65 changes: 33 additions & 32 deletions Script/git_push.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
SECONDS=0
# declare initial seconds
clear
cd ..
echo "piencrypt: -----> Starting Pie Test..";
echo -en '\n';
pip install --upgrade piencrypt;
echo -en '\n';
cd Test
python pie_test.py;
echo -en '\n';
echo "piencrypt: -----> Test completed"
echo -en '\n';
cd ..
echo "piencrypt: -----> Tracking files..";
echo -en '\n';
git add .;
echo -en '\n';
read -p "Enter the push reason: " push_type
git commit -m "$push_type";
echo -en '\n';
echo "piencrypt: -----> Commit completed";
echo -en '\n';
git push origin master;
echo -en '\n';
echo "..";
echo '----------------------------------------------------------------------';
echo "piencrypt: -----> Push Successfull";
echo -en '\n';
# get elapsed time
duration=$SECONDS
echo "$(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
SECONDS=0
# declare initial seconds
clear
cd ..
echo "piencrypt: -----> Starting Pie Test..";
echo -en '\n';
pip install --upgrade piencrypt;
echo -en '\n';
cd Test
python pie_test.py;
echo -en '\n';
echo "piencrypt: -----> Test completed"
echo -en '\n';
cd ..
echo "piencrypt: -----> Tracking files..";
echo -en '\n';
git add .;
echo -en '\n';
read -p "Enter the push reason: " push_type
git commit -m "$push_type";
echo -en '\n';
echo "piencrypt: -----> Commit completed";
echo -en '\n';
# git push origin master;
git push origin develop;
echo -en '\n';
echo "..";
echo '----------------------------------------------------------------------';
echo "piencrypt: -----> Push Successfull";
echo -en '\n';
# get elapsed time
duration=$SECONDS
echo "$(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
68 changes: 34 additions & 34 deletions Script/heroku_push.sh
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
SECONDS=0
# declare initial seconds
clear
cd ..
echo "piencrypt: -----> Starting Pie Test..";
echo -en '\n';
pip install --upgrade piencrypt;
echo -en '\n';
cd Test
python pie_test.py;
echo -en '\n';
echo "piencrypt: -----> Test completed"
echo -en '\n';
cd ..
cd web
echo "piencrypt: -----> Tracking files..";
echo -en '\n';
git add .;
echo -en '\n';
read -p "Enter the push reason: " reason
git commit -m "$reason";
echo -en '\n';
echo "piencrypt: -----> Commit completed";
echo -en '\n';
git push heroku master;
echo -en '\n';
echo "..";
echo '----------------------------------------------------------------------';
echo "piencrypt: -----> Deployment Successfull";
echo -en '\n';
# get elapsed time
duration=$SECONDS
echo "$(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
cd ..
SECONDS=0
# declare initial seconds
clear
cd ..
echo "piencrypt: -----> Starting Pie Test..";
echo -en '\n';
pip install --upgrade piencrypt;
echo -en '\n';
cd Test
python pie_test.py;
echo -en '\n';
echo "piencrypt: -----> Test completed"
echo -en '\n';
cd ..
cd web
echo "piencrypt: -----> Tracking files..";
echo -en '\n';
git add .;
echo -en '\n';
read -p "Enter the push reason: " reason
git commit -m "$reason";
echo -en '\n';
echo "piencrypt: -----> Commit completed";
echo -en '\n';
git push heroku master;
echo -en '\n';
echo "..";
echo '----------------------------------------------------------------------';
echo "piencrypt: -----> Deployment Successfull";
echo -en '\n';
# get elapsed time
duration=$SECONDS
echo "$(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
cd ..
Empty file added build/lib/piencrypt/__init__.py
Empty file.
55 changes: 55 additions & 0 deletions build/lib/piencrypt/pie.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@

from cryptography.fernet import Fernet
pie_hash = '03c1d04aeffd72151933b2295df5b484547e00ead9d001126aef03e6179a9332'

key = b'2PlCwYo0bGpbWBQ6onpmmKv9T8lshcJhI7R00NKxKpM='
clipher = Fernet(key)

class PiEncrypt:

def __init__(self, loc):
self.loc = loc

# save the data of the picture as bytes
def get_data(self):
with open(self.loc , 'rb') as f, open('backup.txt', 'wb') as b:
r = f.read()
b.write(r)

# hides the disired data into the picture
def hide_data(self, data):
self.data = data
# encrypt the data
encrypt_text = clipher.encrypt(bytes(pie_hash + self.data, encoding="ascii"))
# save to the image
with open(self.loc, 'ab') as f:
f.write(bytes(pie_hash, encoding="ascii") + encrypt_text)

# read the hidden data from the picture
def read_data(self):
with open(self.loc, 'rb') as f:
content = f.read()
list = content.split(bytes(pie_hash, encoding="ascii"))
data = list[1]
# dencrypt the text
dencrypt_text = clipher.decrypt(data).decode("utf-8")
# seperate by pie_hash
output = dencrypt_text.split(pie_hash)
return output[1]

# revert the picture from the backup bytes file
def revert(self):
with open('backup.txt', 'rb') as f, open(self.loc, 'wb') as e:
r = f.read()
e.write(r)

if __name__ == '__main__':
# print(key)
# print(encrypt_text)
# print(dencrypt_text)
p = PiEncrypt('pic.png')
p.get_data()
p.hide_data("Hello this is piencrypt test")
r = p.read_data()
p.revert()
print(r)
30 changes: 30 additions & 0 deletions build/lib/piencrypt/piencrypt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# save the data of the picture as bytes
def get_data(loc):
with open(loc , 'rb') as f, open('binary.txt', 'wb') as b:
r = f.read()
b.write(r)
# hides the disired data into the picture
def hide_data(loc, data):
with open(loc, 'ab') as f:
f.write(bytes("HERE" + data , encoding="ascii"))
# read the hidden data from the picture
def read_data(loc):
with open(loc, 'rb') as f:
content = f.read()
list = content.split(b'HERE')
# print(f.read())
return list[1].decode("utf-8")
# revert the picture from the backup bytes file
def revert(loc):
with open('binary.txt', 'rb') as f, open(loc, 'wb') as e:
r = f.read()
e.write(r)


if __name__ == '__main__':
get_data('img.PNG')
# p.revert()
# p.hide_data("Hello my name is Sid")
# r = p.read_data()
# print(r)

Loading