aboutsummaryrefslogtreecommitdiff
path: root/src/hash/pjw.c
diff options
context:
space:
mode:
authoramelia squires <[email protected]>2025-09-30 18:10:02 -0500
committeramelia squires <[email protected]>2025-09-30 18:10:02 -0500
commita67dc94484cf9869793fc1861914b800a6559a74 (patch)
tree68e9a016380776a6a6d90159722d1514756a4929 /src/hash/pjw.c
parent795284d3b173473003129882739f371f37059adb (diff)
fix indentation!!!
Diffstat (limited to 'src/hash/pjw.c')
-rw-r--r--src/hash/pjw.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/hash/pjw.c b/src/hash/pjw.c
index 188030f..93fc7d4 100644
--- a/src/hash/pjw.c
+++ b/src/hash/pjw.c
@@ -4,7 +4,7 @@
#include <stdint.h>
struct pjw_hash pjw_init(){
- return (struct pjw_hash){.hash = 0, .high = 0};
+ return (struct pjw_hash){.hash = 0, .high = 0};
}
int pjw_free_l(lua_State* L){
@@ -12,22 +12,22 @@ int pjw_free_l(lua_State* L){
}
void pjw_update(uint8_t* in, size_t len, struct pjw_hash* hash){
- for(int i = 0; i != len; i++){
- hash->hash = (hash->hash << 4) + *in++;
- if((hash->high = (hash->hash & 0xf0000000)))
- hash->hash ^= hash->high >> 24;
- hash->hash &= ~hash->high;
- }
+ for(int i = 0; i != len; i++){
+ hash->hash = (hash->hash << 4) + *in++;
+ if((hash->high = (hash->hash & 0xf0000000)))
+ hash->hash ^= hash->high >> 24;
+ hash->hash &= ~hash->high;
+ }
}
uint32_t pjw_final(struct pjw_hash* hash){
- return hash->hash;
+ return hash->hash;
}
uint32_t pjw(uint8_t* in, size_t len){
- struct pjw_hash a = pjw_init();
- pjw_update(in, len, &a);
- return pjw_final(&a);
+ struct pjw_hash a = pjw_init();
+ pjw_update(in, len, &a);
+ return pjw_final(&a);
}
common_hash_clone(pjw);
@@ -43,14 +43,14 @@ int l_pjw_final(lua_State* L){
}
int l_pjw(lua_State* L){
- if(lua_gettop(L) == 0) return l_pjw_init(L);
- size_t len = 0;
- uint8_t* a = (uint8_t*)luaL_checklstring(L, 1, &len);
+ if(lua_gettop(L) == 0) return l_pjw_init(L);
+ size_t len = 0;
+ uint8_t* a = (uint8_t*)luaL_checklstring(L, 1, &len);
- char digest[32];
+ char digest[32];
- uint32_t u = pjw(a, len);
- sprintf(digest,"%08x",u);
- lua_pushstring(L, digest);
- return 1;
+ uint32_t u = pjw(a, len);
+ sprintf(digest,"%08x",u);
+ lua_pushstring(L, digest);
+ return 1;
}