From b6127c880764d346d16f403618eb51fa282fd4aa Mon Sep 17 00:00:00 2001 From: hartwigja62500 Date: Mon, 22 Oct 2018 16:49:16 +0200 Subject: [PATCH] prakt2 --- .idea/vcs.xml | 6 ++++++ krypto/__init__.py | 0 krypto/hashes.py | 12 ++++++++++++ starthash.py | 9 +++++++++ teste_meine_funktionen.py | 8 ++++++++ 5 files changed, 35 insertions(+) create mode 100644 .idea/vcs.xml create mode 100644 krypto/__init__.py create mode 100644 krypto/hashes.py create mode 100644 starthash.py create mode 100644 teste_meine_funktionen.py diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/krypto/__init__.py b/krypto/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/krypto/hashes.py b/krypto/hashes.py new file mode 100644 index 0000000..3111f23 --- /dev/null +++ b/krypto/hashes.py @@ -0,0 +1,12 @@ +import sys + +def hashMod(bytes): + result = 0 + for byte in bytes: + result += byte + return result % sys.maxsize + + +if __name__ == "__main__": + test_hashmod = hashMod("test".encode('utf-8')) + print("Teste function hashMod : ", test_hashmod) diff --git a/starthash.py b/starthash.py new file mode 100644 index 0000000..356b124 --- /dev/null +++ b/starthash.py @@ -0,0 +1,9 @@ +import krypto.hashes + +aufruf_string = 'Hello' +aufruf_string = aufruf_string.encode('utf-8') + +print(aufruf_string) +aufruf_string = krypto.hashes.hashMod(aufruf_string) + +print(aufruf_string) diff --git a/teste_meine_funktionen.py b/teste_meine_funktionen.py new file mode 100644 index 0000000..adff21d --- /dev/null +++ b/teste_meine_funktionen.py @@ -0,0 +1,8 @@ +import krypto.hashes +import unittest +class TestHash(unittest.TestCase): + + def teste_hashMod(self): + first_param = krypto.hashes.hashMod('Hi'.encode('utf-8')) + second_param = krypto.hashes.hashMod('Hi'.encode('utf-8')) + self.assertEquals(first_param, second_param, 'fehler ungleich') \ No newline at end of file