diff --git a/.github/workflows/devskim-analysis.yml b/.github/workflows/devskim-analysis.yml index 71cc253..89c3c0e 100644 --- a/.github/workflows/devskim-analysis.yml +++ b/.github/workflows/devskim-analysis.yml @@ -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' diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index bb5da57..0e9c801 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -5,9 +5,9 @@ name: Pie Test on: push: - branches: [ master ] + branches: [ master, develop ] pull_request: - branches: [ master ] + branches: [ master, develop ] jobs: test: diff --git a/.gitignore b/.gitignore index 8baf7d3..db0c0b8 100644 --- a/.gitignore +++ b/.gitignore @@ -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 \ No newline at end of file +# build/ +Script/test.sh +# web/ +.pytest_cache/ \ No newline at end of file diff --git a/Example/main.py b/Example/main.py index b2c9c53..4bca0b9 100644 --- a/Example/main.py +++ b/Example/main.py @@ -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) diff --git a/Helper/requirements.txt b/Helper/requirements.txt new file mode 100644 index 0000000..aafb8fc Binary files /dev/null and b/Helper/requirements.txt differ diff --git a/Helper/steps.txt b/Helper/steps.txt new file mode 100644 index 0000000..864673b --- /dev/null +++ b/Helper/steps.txt @@ -0,0 +1,5 @@ +build setup : python setup.py sdist bdist_wheel + +upload : twine upload dist/* + +untrack files : git rm --cached piencrypt -r \ No newline at end of file diff --git a/Script/build.sh b/Script/build.sh index 744b621..4bb281b 100644 --- a/Script/build.sh +++ b/Script/build.sh @@ -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 \ No newline at end of file diff --git a/Script/git_push.sh b/Script/git_push.sh index cd2fc23..be0242f 100644 --- a/Script/git_push.sh +++ b/Script/git_push.sh @@ -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." diff --git a/Script/heroku_push.sh b/Script/heroku_push.sh index 8e8e3db..acfab52 100644 --- a/Script/heroku_push.sh +++ b/Script/heroku_push.sh @@ -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 .. diff --git a/build/lib/piencrypt/__init__.py b/build/lib/piencrypt/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/build/lib/piencrypt/pie.py b/build/lib/piencrypt/pie.py new file mode 100644 index 0000000..a38284f --- /dev/null +++ b/build/lib/piencrypt/pie.py @@ -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) diff --git a/build/lib/piencrypt/piencrypt.py b/build/lib/piencrypt/piencrypt.py new file mode 100644 index 0000000..9d38f65 --- /dev/null +++ b/build/lib/piencrypt/piencrypt.py @@ -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) + diff --git a/piencrypt.egg-info/PKG-INFO b/piencrypt.egg-info/PKG-INFO new file mode 100644 index 0000000..bf5c436 --- /dev/null +++ b/piencrypt.egg-info/PKG-INFO @@ -0,0 +1,99 @@ +Metadata-Version: 2.1 +Name: piencrypt +Version: 0.7.5.6 +Summary: Encrypt your crucial data into Image file +Home-page: UNKNOWN +Author: Throttlerz (Siddhartha Roy) +Author-email: +License: UNKNOWN +Keywords: python,image processing,encrypt,decrypt,hide messages,data store +Platform: UNKNOWN +Classifier: Development Status :: 1 - Planning +Classifier: Intended Audience :: Developers +Classifier: Programming Language :: Python :: 3 +Classifier: Operating System :: Unix +Classifier: Operating System :: MacOS :: MacOS X +Classifier: Operating System :: Microsoft :: Windows +Description-Content-Type: text/markdown +License-File: LICENSE + + +## PiEncrypt + +[![Pie Test](https://github.com/sid86-dev/PiEncrypt/actions/workflows/python-app.yml/badge.svg)](https://github.com/sid86-dev/PiEncrypt/actions/workflows/python-app.yml) +[![DevSkim](https://github.com/sid86-dev/PiEncrypt/actions/workflows/devskim-analysis.yml/badge.svg)](https://github.com/sid86-dev/PiEncrypt/actions/workflows/devskim-analysis.yml) +![PyPI - Python Version](https://img.shields.io/pypi/pyversions/piencrypt) + +### `pip install piencrypt` + +> ### Encrypt your crucial data into Image file. + +
+ +### Minimal app + +```python +from piencrypt import pie + +r = pie.PiEncrypt('pic.png') +r.get_data() + +r.hide_data("Hello my name is Sid") + +read = r.read_data() + +r.revert() +print(read) +``` + +
+ + + + #### Initialize and create a backup of the picture as bytes + + ```python + r = pie.PiEncrypt('pic.png') + + r.get_data() +``` +> *pic.jpg should be replaced by your picture name present in the root directory* + +
+ + + +#### Hide the disired data into the picture + + ```python + r.hide_data("Hello my name is Sid") +``` + +
+ + + + #### Read the hidden data from the picture + + ```python + read = r.read_data() + + print(read) +``` +
+ + + + #### Revert the picture from the backup file + + ```python + r.revert() +``` + +
+ +https://pypi.org/project/piencrypt/ + +## Repeat ! + + diff --git a/piencrypt.egg-info/SOURCES.txt b/piencrypt.egg-info/SOURCES.txt new file mode 100644 index 0000000..a00d51a --- /dev/null +++ b/piencrypt.egg-info/SOURCES.txt @@ -0,0 +1,10 @@ +LICENSE +README.md +setup.py +piencrypt/__init__.py +piencrypt/pie.py +piencrypt.egg-info/PKG-INFO +piencrypt.egg-info/SOURCES.txt +piencrypt.egg-info/dependency_links.txt +piencrypt.egg-info/requires.txt +piencrypt.egg-info/top_level.txt \ No newline at end of file diff --git a/piencrypt.egg-info/dependency_links.txt b/piencrypt.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/piencrypt.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/piencrypt.egg-info/requires.txt b/piencrypt.egg-info/requires.txt new file mode 100644 index 0000000..0d38bc5 --- /dev/null +++ b/piencrypt.egg-info/requires.txt @@ -0,0 +1 @@ +cryptography diff --git a/piencrypt.egg-info/top_level.txt b/piencrypt.egg-info/top_level.txt new file mode 100644 index 0000000..22a4901 --- /dev/null +++ b/piencrypt.egg-info/top_level.txt @@ -0,0 +1 @@ +piencrypt diff --git a/web b/web index 6585aee..7566f4c 160000 --- a/web +++ b/web @@ -1 +1 @@ -Subproject commit 6585aee7483f46873eb3be73b0d6e8a4e5832303 +Subproject commit 7566f4cf9169df7709eea0dd4d479bbbf15fbf5e