From 7f096c85dcb7729898f8418b2c7d04e9e9c76713 Mon Sep 17 00:00:00 2001 From: lomna-dev Date: Wed, 26 Apr 2023 21:57:14 +0530 Subject: [PATCH] Changing header name Changing names and modifying readme. --- README.md | 10 +++++----- output.flow | 6 +++--- example.c => src/example.c | 4 ++-- nsha1.h => src/sha1.h | 12 ++++++------ 4 files changed, 16 insertions(+), 16 deletions(-) rename example.c => src/example.c (70%) rename nsha1.h => src/sha1.h (95%) diff --git a/README.md b/README.md index bdb6ecf..7eaa2dc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# Not sha1 +# SHA1 in C -This was a failed attempt to create SHA1 algorithm in C. The algorithm achieved still seems sensitive to small changes in text files. So maybe it can be used in stuff like VCS and build systems. +SHA1 algorithm in C. A single function that reads a file and outputs it's sha1sum. ## How to use @@ -18,6 +18,6 @@ python3 flow clean The "library" is only adding: -1. NSHA1_Result struct to store result -2. nsha1file, a function to get nsha1 of a file. -3. leftRotate32, a macro to circular shift 32 bit unsigned integers. \ No newline at end of file +1. SHA1_Result struct to store result +2. SHA1_sha1file, a function to get nsha1 of a file. +3. leftRotate32, a function to circular shift 32 bit unsigned integers. \ No newline at end of file diff --git a/output.flow b/output.flow index 9d6be5d..c08a15f 100644 --- a/output.flow +++ b/output.flow @@ -1,5 +1,5 @@ -example.c -nsha1.h +src/example.c +src/sha1.h ;!run!; -gcc example.c +gcc src/example.c -I src ;!end!; \ No newline at end of file diff --git a/example.c b/src/example.c similarity index 70% rename from example.c rename to src/example.c index 3908832..51d2361 100644 --- a/example.c +++ b/src/example.c @@ -1,9 +1,9 @@ -#include "nsha1.h" +#include "sha1.h" #include #include int main(){ - NSHA1_Result r = nsha1file("test"); + SHA1_Result r = SHA1_sha1file("test"); char buffer[41]; printf("%x%x%x%x%x", r.h0, r.h1, r.h2, r.h3, r.h4); return 0; diff --git a/nsha1.h b/src/sha1.h similarity index 95% rename from nsha1.h rename to src/sha1.h index 838d414..9cc0eea 100644 --- a/nsha1.h +++ b/src/sha1.h @@ -1,5 +1,5 @@ -#ifndef INCLUDED_NSHA1_H -#define INCLUDED_NSHA1_H +#ifndef INCLUDED_SHA1_H +#define INCLUDED_SHA1_H #include #include @@ -9,18 +9,18 @@ uint32_t leftRotate32( uint32_t N, uint32_t D){ return ((N << D) | (N >> (32-D))); } -typedef struct NSHA1_Result{ +typedef struct SHA1_Result{ uint32_t h0; uint32_t h1; uint32_t h2; uint32_t h3; uint32_t h4; -} NSHA1_Result; +} SHA1_Result; -NSHA1_Result nsha1file(char *filename){ +SHA1_Result SHA1_sha1file(char *filename){ FILE* file; - NSHA1_Result r; + SHA1_Result r; uint32_t number_of_chuncks = 0; uint32_t size_in_bytes = 0; uint64_t size_in_bits = 0;