From cc41c487e560c33e98e3da13c94906f65ecc51b6 Mon Sep 17 00:00:00 2001 From: JuliBergamasco Date: Fri, 20 May 2022 16:30:32 -0300 Subject: [PATCH 1/2] update README --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index e69de29..020697e 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,3 @@ +# Hash Validator Library + +This project aims to check hash values from files using sha256 and compare them between tow given files or between many files and a respective hash value for each one. \ No newline at end of file From 233a25286de75e5c945a003d8989e2900539f25c Mon Sep 17 00:00:00 2001 From: JuliBergamasco Date: Fri, 20 May 2022 16:31:12 -0300 Subject: [PATCH 2/2] update hash validator case 2 --- hash_validator/libreria hash.ipynb | 62 ++++++++++++++++-------------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/hash_validator/libreria hash.ipynb b/hash_validator/libreria hash.ipynb index d22f9af..699006c 100644 --- a/hash_validator/libreria hash.ipynb +++ b/hash_validator/libreria hash.ipynb @@ -27,7 +27,7 @@ }, { "cell_type": "code", - "execution_count": 194, + "execution_count": 18, "id": "aec0dd78", "metadata": {}, "outputs": [], @@ -35,14 +35,12 @@ "def check_hash(files:list or str, # revisar\n", " hash_val:list or str=None):\n", " \"\"\"\n", - " Check hash values from files usinig sha256 and compare with hash_val, comparison is by position\n", + " Check hash values from files using sha256 and compare with hash_val, where comparison\n", + " is by position, or between two given files.\n", " \n", " Param:\n", - " files:list, files' path list\n", - " hash_val: list hases' val list\n", - " between: bool, if it's true the list of files will compare its own hash values\n", - " \n", - " \n", + " files: list or str, files' path list.\n", + " hash_val: list or str, hashes' values list.\n", " \"\"\"\n", " \n", " # DONE: validate len in two list --> DONE\n", @@ -77,7 +75,7 @@ " 'ok':[],\n", " 'not_ok':[] \n", " }\n", - " for file, val in tuple(zip(files, hash_val)):\n", + " for file, val in zip(files, hash_val):\n", " tmp_hash = sha256sum(file)\n", " if tmp_hash == val:\n", " dict_result['ok'].append(file)\n", @@ -87,11 +85,11 @@ " if dict_result['not_ok']:\n", " print(\"Check the files, the hash aren't the same:{} \".format(','.join(dict_result['not_ok'])))\n", " else:\n", - " print('Congratulations, hash are the same!! Continue working slave.')\n", + " print('Congratulations, hash are the same!! Continue working, slave.')\n", "\n", " else:\n", - " if len_files < 2: #--> Use case 2\n", - " raise Exception(\"List of files must have at least two files if hashes are not provided.\")\n", + " if len_files != 2: #--> Use case 2\n", + " raise Exception(\"List of files must have two files if hashes are not provided.\")\n", "\n", " hash_list = []\n", " for e in files:\n", @@ -103,7 +101,7 @@ }, { "cell_type": "code", - "execution_count": 195, + "execution_count": 19, "id": "a981fa48", "metadata": {}, "outputs": [], @@ -115,15 +113,15 @@ " ]\n", "\n", "hash_val = [\n", - " #'9ef7a2f47e2871adef6616556f1499bbd2702748e371104a63df4246a7232136',\n", - " # '38a0539db6a864881d9fa8a60157e713fd8b63924cea9d83a83f12b9a3a50893',\n", + " '9ef7a2f47e2871adef6616556f1499bbd2702748e371104a63df4246a7232136',\n", + " '38a0539db6a864881d9fa8a60157e713fd8b63924cea9d83a83f12b9a3a50893',\n", " # 'e1f148287023fe1e7a7d6087e543a11fb49e551cead6d78e1c2a7f25235b940e'\n", " ]" ] }, { "cell_type": "code", - "execution_count": 196, + "execution_count": 20, "id": "fdfb7435", "metadata": {}, "outputs": [], @@ -133,15 +131,20 @@ }, { "cell_type": "code", - "execution_count": 197, + "execution_count": 21, "id": "d36a1f2a", "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "Check the files, the hash aren't the same:../data/experimental/weather_zipcodes.csv,../data/experimental/weather_zipcodes.csv \n" + "ename": "Exception", + "evalue": "Lists don't have the same length.", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mException\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mcheck_hash\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfiles\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mhash_val\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m\u001b[0m in \u001b[0;36mcheck_hash\u001b[0;34m(files, hash_val)\u001b[0m\n\u001b[1;32m 27\u001b[0m \u001b[0;32mraise\u001b[0m \u001b[0mException\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"List of files is empty.\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 28\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0mlen_files\u001b[0m \u001b[0;34m!=\u001b[0m \u001b[0mlen_hash\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0mlen_hash\u001b[0m \u001b[0;34m!=\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;31m# --> Use case 3\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 29\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mException\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Lists don't have the same length.\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 30\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 31\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mException\u001b[0m: Lists don't have the same length." ] } ], @@ -151,24 +154,24 @@ }, { "cell_type": "code", - "execution_count": 180, + "execution_count": 22, "id": "4f2b3fae", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "[('../data/New_Launches_data_test.csv',\n", - " 'd429dfcbd43d91efd7750b09c0c4256dc2fd52713b2bae11a3f036566cb854a1')]" + "[('../../data/sumbission_3.csv',\n", + " '9ef7a2f47e2871adef6616556f1499bbd2702748e371104a63df4246a7232136')]" ] }, - "execution_count": 180, + "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "list(zip([files], hash_val))" + "list(zip(files, hash_val))" ] }, { @@ -183,10 +186,13 @@ } ], "metadata": { + "interpreter": { + "hash": "d15529d9e209a94a09f89984c36a77e2b2b9cb2246b958fadf2bff8346058dd5" + }, "kernelspec": { - "display_name": "Python 3.8.3 64-bit ('topo-chico': conda)", + "display_name": "Python 3.9.2 ('ncr_demo-env')", "language": "python", - "name": "python383jvsc74a57bd048e877130e9be6e1bedc758079db27feb71a89f1334abb10d9b69c71793f0615" + "name": "python3" }, "language_info": { "codemirror_mode": { @@ -198,7 +204,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.3" + "version": "3.9.2" }, "toc": { "base_numbering": 1,