Changing header name

Changing names and modifying readme.
main
lomna-dev 1 year ago
parent c5758a18b7
commit 7f096c85dc

@ -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.
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.

@ -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!;

@ -1,9 +1,9 @@
#include "nsha1.h"
#include "sha1.h"
#include <stdio.h>
#include <stdint.h>
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;

@ -1,5 +1,5 @@
#ifndef INCLUDED_NSHA1_H
#define INCLUDED_NSHA1_H
#ifndef INCLUDED_SHA1_H
#define INCLUDED_SHA1_H
#include <stdint.h>
#include <errno.h>
@ -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;
Loading…
Cancel
Save