add gitignore

This commit is contained in:
Phillip Kühne 2018-10-29 22:11:56 +01:00
parent 5e3f3b7b98
commit 40485c4172
2 changed files with 121 additions and 68 deletions

121
.gitignore vendored Normal file
View File

@ -0,0 +1,121 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

68
main.py
View File

@ -1,68 +0,0 @@
#!/usr/bin/python3
import sys, getopt
def encrypt(string,key):
lowerstr=string.lower()
print("Encrypting "+lowerstr+" with key "+key)
strnums = []
keynums = []
resultnums = []
resultstring = ""
for c in lowerstr:
strnums.append(ord(c)-97)
print(strnums)
for c in key:
keynums.append(ord(c)-97)
print(keynums)
keypointer=0
for n in strnums:
resultnums.append((n+keynums[keypointer])%26)
keypointer = (keypointer+1) % (len(key))
print(resultnums)
for c in resultnums:
resultstring = resultstring+chr(c+97)
print(resultstring)
def decrypt(string,key):
lowerstr=string.lower()
print("Decrypting "+lowerstr+" with key "+key)
strnums = []
keynums = []
resultnums = []
resultstring = ""
for c in lowerstr:
strnums.append(ord(c)-97)
print(strnums)
for c in key:
keynums.append(ord(c)-97)
print(keynums)
keypointer=0
for n in strnums:
resultnums.append((n-keynums[keypointer])%26)
keypointer = (keypointer+1) % (len(key))
print(resultnums)
for c in resultnums:
resultstring = resultstring+chr(c+97)
print(resultstring)
def main(argv):
key = ""
try:
opts, args = getopt.getopt(argv,"hk:e:d:",["key=","encrypt=","decrypt="])
except getopt.GetoptError:
print('test.py -k <key> -e <plain text>')
print('test.py -k <key> -d <encrypted text>')
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print('test.py -k <key> -e <plain text>')
print('test.py -k <key> -d <encrypted text>')
sys.exit()
elif opt in ("-k", "--key"):
key = arg
elif opt in ("-e", "--encrypt"):
encrypt(arg,key)
elif opt in ("-d", "--decrypt"):
decrypt(arg,key)
if __name__ == '__main__':
main(sys.argv[1:])