From 10cfa79ee02030c3be9b4d9414bf7dd845d8cd34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?GOLDERWEB=20=E2=80=93=20Jonathan=20Golder?= Date: Sat, 5 Sep 2015 18:06:17 +0200 Subject: [PATCH] Implement a class/modul RED_FAM for handling redundance families --- red_fam.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 red_fam.py diff --git a/red_fam.py b/red_fam.py new file mode 100644 index 0000000..c0b4848 --- /dev/null +++ b/red_fam.py @@ -0,0 +1,36 @@ + +import hashlib + +class RED_FAM: + + def __init__( self, articlesList ): + """ + Generates a new RED_FAM object + + @param articlesList list List of articles of redundance family + """ + + self.__articlesList = articlesList + + # Make sure we have 8 entrys for pages, if not fill with empty list items + while len( self.__articlesList ) < 8: + self.__articlesList.append( "" ) + + self.__hash = self.__get_fam_hash( ) + + print( self.__hash ) + + + def __get_fam_hash( self ): + """ + Calculates the SHA-1 hash for the articlesList of redundance family. + Since we don't need security SHA-1 is just fine. + + @returns str String with the hexadecimal hash digest + """ + + h = hashlib.sha1() + h.update( str( self.__articlesList ).encode('utf-8') ) + + return h.hexdigest() +