aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/hash/blake.c7
-rw-r--r--src/hash/blake2.c3
-rw-r--r--src/hash/cityhash.c5
-rw-r--r--src/hash/djb2.c5
-rw-r--r--src/hash/farmhash.c7
-rw-r--r--src/hash/fasthash.c7
-rw-r--r--src/hash/fnv.c11
-rw-r--r--src/hash/jenkins.c1
-rw-r--r--src/hash/loselose.c1
-rw-r--r--src/hash/metrohash.c10
-rw-r--r--src/hash/murmur.c1
-rw-r--r--src/hash/pjw.c1
-rw-r--r--src/hash/sdbm.c5
-rw-r--r--src/hash/sha2-256.c7
-rw-r--r--src/hash/spookyhash.c1
-rw-r--r--src/hash/xxh.c3
16 files changed, 34 insertions, 41 deletions
diff --git a/src/hash/blake.c b/src/hash/blake.c
index 4c6d284..7bf1481 100644
--- a/src/hash/blake.c
+++ b/src/hash/blake.c
@@ -2,10 +2,9 @@
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
-#include <math.h>
#include <stdlib.h>
+#include <inttypes.h>
#include "../crypto.h"
-#include "../util.h"
const uint8_t blake_sigma[][16] = {
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
@@ -438,7 +437,7 @@ void blake512_final(struct blake512_hash* hash, char* out_stream){
_blake512_final(hash, out_stream);
for(int i = 0; i != 8; i++){
- sprintf(out_stream + 16 * i, "%016llx", (hash->hash)[i]);
+ sprintf(out_stream + 16 * i, "%016"PRIx64, (hash->hash)[i]);
}
memcpy(hash, &old_hash, sizeof * hash);
@@ -469,7 +468,7 @@ void blake384_final(struct blake384_hash* hash, char* out_stream){
_blake512_final(hash, out_stream);
for(int i = 0; i != 6; i++){
- sprintf(out_stream + 16 * i, "%016llx", (hash->hash)[i]);
+ sprintf(out_stream + 16 * i, "%016"PRIx64, (hash->hash)[i]);
}
memcpy(hash, &old_hash, sizeof * hash);
diff --git a/src/hash/blake2.c b/src/hash/blake2.c
index 95d878f..5f38bba 100644
--- a/src/hash/blake2.c
+++ b/src/hash/blake2.c
@@ -2,10 +2,7 @@
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
-#include <math.h>
#include "../crypto.h"
-//#include "blake2.h"
-#include "../util.h"
#include "lua5.4/lua.h"
void mix2b(uint64_t* a, uint64_t* b, uint64_t* c, uint64_t* d, int64_t x, int64_t y){
diff --git a/src/hash/cityhash.c b/src/hash/cityhash.c
index f6f419a..18e35e5 100644
--- a/src/hash/cityhash.c
+++ b/src/hash/cityhash.c
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <stdint.h>
+#include <inttypes.h>
#include "cityhash.h"
uint32_t rot32(uint32_t val, int shift) {
@@ -411,7 +412,7 @@ int l_cityhash64(lua_State* L){
char digest[64];
uint64_t u = cityhash64(a, len);
- sprintf(digest,"%016llx",u);
+ sprintf(digest,"%016"PRIx64,u);
lua_pushstring(L, digest);
return 1;
}
@@ -424,7 +425,7 @@ int l_cityhash128(lua_State* L){
uint64_t u1, u2;
cityhash128(a, len, &u1, &u2);
- sprintf(digest,"%08llx%08llx",u1, u2);
+ sprintf(digest,"%08"PRIx64"%08"PRIx64,u1, u2);
lua_pushstring(L, digest);
return 1;
}
diff --git a/src/hash/djb2.c b/src/hash/djb2.c
index 827d468..d17c163 100644
--- a/src/hash/djb2.c
+++ b/src/hash/djb2.c
@@ -1,6 +1,7 @@
#include "../crypto.h"
#include <stdio.h>
#include <stdint.h>
+#include <inttypes.h>
struct djb2_hash djb2_init(){
return (struct djb2_hash){.hash = 5381};
@@ -31,7 +32,7 @@ int l_djb2_final(lua_State* L){
struct djb2_hash* a = (struct djb2_hash*)lua_touserdata(L, 1);
uint32_t u = djb2_final(a);
char digest[64];
- sprintf(digest,"%08x",u);
+ sprintf(digest,"%08"PRIx32,u);
lua_pushstring(L, digest);
return 1;
}
@@ -44,7 +45,7 @@ int l_djb2(lua_State* L){
char digest[64];
uint32_t u = djb2(a, len);
- sprintf(digest,"%08x",u);
+ sprintf(digest,"%08"PRIx32,u);
lua_pushstring(L, digest);
return 1;
}
diff --git a/src/hash/farmhash.c b/src/hash/farmhash.c
index 462bf4b..3db7ef4 100644
--- a/src/hash/farmhash.c
+++ b/src/hash/farmhash.c
@@ -1,7 +1,6 @@
-#include "../util.h"
#include "../crypto.h" //include city hash too
#include <stdint.h>
-
+#include <inttypes.h>
uint32_t farmhash32len13to24(uint8_t* in, size_t len) {
uint32_t seed = 0;
uint32_t a = UNALIGNED_LOAD32(in - 4 + (len >> 1));
@@ -151,7 +150,7 @@ int l_farmhash32(lua_State* L){
char digest[32];
uint32_t u = farmhash32(a, len);
- sprintf(digest,"%04x",u);
+ sprintf(digest,"%04"PRIx32,u);
lua_pushstring(L, digest);
return 1;
}
@@ -163,7 +162,7 @@ int l_farmhash64(lua_State* L){
char digest[64];
uint64_t u = farmhash64(a, len);
- sprintf(digest,"%016llx",u);
+ sprintf(digest,"%016"PRIx64,u);
lua_pushstring(L, digest);
return 1;
}
diff --git a/src/hash/fasthash.c b/src/hash/fasthash.c
index b27b6b9..12ec3be 100644
--- a/src/hash/fasthash.c
+++ b/src/hash/fasthash.c
@@ -1,6 +1,5 @@
-#include "../util.h"
#include "../crypto.h"
-#include <stdio.h>
+#include <inttypes.h>
#include <stdint.h>
//almost entirely taken from https://github.com/ztanml/fast-hash/blob/master/fasthash.c
@@ -62,7 +61,7 @@ int l_fasthash64(lua_State* L){
char digest[64];
uint64_t u = fasthash64(a, len, seed);
- sprintf(digest,"%016llx",u);
+ sprintf(digest,"%016"PRIx64,u);
lua_pushstring(L, digest);
return 1;
}
@@ -77,7 +76,7 @@ int l_fasthash32(lua_State* L){
char digest[32];
uint32_t u = fasthash32(a, len, seed);
- sprintf(digest,"%04x",u);
+ sprintf(digest,"%04"PRIx32,u);
lua_pushstring(L, digest);
return 1;
}
diff --git a/src/hash/fnv.c b/src/hash/fnv.c
index 6214ea5..48b351e 100644
--- a/src/hash/fnv.c
+++ b/src/hash/fnv.c
@@ -1,6 +1,5 @@
-#include "../util.h"
#include "../crypto.h"
-#include <stdio.h>
+#include <inttypes.h>
#include <stdint.h>
struct fnv_1_hash fnv_1_init(enum fnv_version A){
@@ -52,7 +51,7 @@ int l_fnv_##v##_final(lua_State* L){\
struct fnv_1_hash* a = (struct fnv_1_hash*)lua_touserdata(L, 1);\
uint64_t u = fnv_1_final(a);\
char digest[64];\
- sprintf(digest,"%16llx",u);\
+ sprintf(digest,"%16"PRIx64,u);\
lua_pushstring(L, digest);\
return 1;\
}
@@ -69,7 +68,7 @@ int l_fnv_0(lua_State* L){
char digest[64];
uint64_t u = fnv_1(a, len, v_0);
- sprintf(digest,"%16llx",u);
+ sprintf(digest,"%16"PRIx64,u);
lua_pushstring(L, digest);
return 1;
}
@@ -82,7 +81,7 @@ int l_fnv_1(lua_State* L){
char digest[64];
uint64_t u = fnv_1(a, len, v_1);
- sprintf(digest,"%16llx",u);
+ sprintf(digest,"%16"PRIx64,u);
lua_pushstring(L, digest);
return 1;
}
@@ -95,7 +94,7 @@ int l_fnv_a(lua_State* L){
char digest[64];
uint64_t u = fnv_1(a, len, v_a);
- sprintf(digest,"%16llx",u);
+ sprintf(digest,"%16"PRIx64,u);
lua_pushstring(L, digest);
return 1;
}
diff --git a/src/hash/jenkins.c b/src/hash/jenkins.c
index 6775988..8a417c6 100644
--- a/src/hash/jenkins.c
+++ b/src/hash/jenkins.c
@@ -1,4 +1,3 @@
-#include "../util.h"
#include "../crypto.h"
#include <stdio.h>
#include <stdint.h>
diff --git a/src/hash/loselose.c b/src/hash/loselose.c
index 9724e0c..e99987c 100644
--- a/src/hash/loselose.c
+++ b/src/hash/loselose.c
@@ -1,4 +1,3 @@
-#include "../util.h"
#include "../crypto.h"
#include <stdio.h>
#include <stdint.h>
diff --git a/src/hash/metrohash.c b/src/hash/metrohash.c
index e27dfe7..080091b 100644
--- a/src/hash/metrohash.c
+++ b/src/hash/metrohash.c
@@ -1,5 +1,5 @@
#include "../crypto.h"
-#include <stdio.h>
+#include <inttypes.h>
#include <stdint.h>
#define u64(a) (*(uint64_t*)a)
@@ -169,7 +169,7 @@ int l_metrohash64_v1(lua_State* L){
char digest[64];
uint64_t u = metrohash64(a, len, seed, v1);
- sprintf(digest,"%016llx",u);
+ sprintf(digest,"%016"PRIx64,u);
lua_pushstring(L, digest);
return 1;
}
@@ -184,7 +184,7 @@ int l_metrohash64_v2(lua_State* L){
char digest[64];
uint64_t u = metrohash64(a, len, seed, v2);
- sprintf(digest,"%016llx",u);
+ sprintf(digest,"%016"PRIx64,u);
lua_pushstring(L, digest);
return 1;
}
@@ -200,7 +200,7 @@ int l_metrohash128_v1(lua_State* L){
uint64_t u1, u2;
metrohash128(a, len, seed, &u1, &u2, v1);
- sprintf(digest,"%016llx%016llx",u1,u2);
+ sprintf(digest,"%016"PRIx64"%016"PRIx64,u1,u2);
lua_pushstring(L, digest);
return 1;
}
@@ -216,7 +216,7 @@ int l_metrohash128_v2(lua_State* L){
uint64_t u1, u2;
metrohash128(a, len, seed, &u1, &u2, v2);
- sprintf(digest,"%016llx%016llx",u1,u2);
+ sprintf(digest,"%016"PRIx64"%016"PRIx64,u1,u2);
lua_pushstring(L, digest);
return 1;
}
diff --git a/src/hash/murmur.c b/src/hash/murmur.c
index 18f2887..d191d75 100644
--- a/src/hash/murmur.c
+++ b/src/hash/murmur.c
@@ -1,4 +1,3 @@
-#include "../util.h"
#include "../crypto.h"
#include <stdio.h>
#include <stdint.h>
diff --git a/src/hash/pjw.c b/src/hash/pjw.c
index c96354d..7d37275 100644
--- a/src/hash/pjw.c
+++ b/src/hash/pjw.c
@@ -1,4 +1,3 @@
-#include "../util.h"
#include "../crypto.h"
#include <stdio.h>
diff --git a/src/hash/sdbm.c b/src/hash/sdbm.c
index a2f1acc..2387301 100644
--- a/src/hash/sdbm.c
+++ b/src/hash/sdbm.c
@@ -1,6 +1,7 @@
#include "../crypto.h"
#include <stdio.h>
#include <stdint.h>
+#include <inttypes.h>
struct sdbm_hash sdbm_init(){
return (struct sdbm_hash){.hash = 0};
@@ -30,7 +31,7 @@ int l_sdbm_final(lua_State* L){
struct sdbm_hash* a = (struct sdbm_hash*)lua_touserdata(L, 1);
uint64_t u = sdbm_final(a);
char digest[64];
- sprintf(digest,"%016llx",u);
+ sprintf(digest,"%016"PRIx64,u);
lua_pushstring(L, digest);
return 1;
}
@@ -43,7 +44,7 @@ int l_sdbm(lua_State* L){
char digest[64];
uint64_t u = sdbm(a, len);
- sprintf(digest,"%016llx",u);
+ sprintf(digest,"%016"PRIx64,u);
lua_pushstring(L, digest);
return 1;
}
diff --git a/src/hash/sha2-256.c b/src/hash/sha2-256.c
index d4a685a..7e37d9d 100644
--- a/src/hash/sha2-256.c
+++ b/src/hash/sha2-256.c
@@ -1,9 +1,9 @@
-#include "../util.h"
#include "../crypto.h"
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdio.h>
+#include <inttypes.h>
const uint64_t k[80] = {0x428a2f98d728ae22, 0x7137449123ef65cd, 0xb5c0fbcfec4d3b2f, 0xe9b5dba58189dbbc, 0x3956c25bf348b538,
0x59f111f1b605d019, 0x923f82a4af194f9b, 0xab1c5ed5da6d8118, 0xd807aa98a3030242, 0x12835b0145706fbe,
@@ -175,7 +175,8 @@ void sha512_final(struct sha512_hash* hash, char* out_stream){
_sha512_t_final(hash);
- sprintf((char*)out_stream, "%016llx%016llx%016llx%016llx%016llx%016llx%016llx%016llx", hash->h0, hash->h1, hash->h2, hash->h3, hash->h4, hash->h5, hash->h6, hash->h7);
+ sprintf((char*)out_stream, "%016"PRIx64"%016"PRIx64"%016"PRIx64"%016"PRIx64"%016"PRIx64"%016"PRIx64"%016"PRIx64"%016"PRIx64
+ , hash->h0, hash->h1, hash->h2, hash->h3, hash->h4, hash->h5, hash->h6, hash->h7);
/*sprintf((char*)out_stream, "%s%016llx", out_stream, hash->h1);
sprintf((char*)out_stream, "%s%016llx", out_stream, hash->h2);
sprintf((char*)out_stream, "%s%016llx", out_stream, hash->h3);
@@ -196,7 +197,7 @@ void sha384_final(struct sha512_hash* hash, char* out_stream){
_sha512_t_final(hash);
- sprintf((char*)out_stream, "%016llx%016llx%016llx%016llx%016llx%016llx", hash->h0, hash->h1, hash->h2, hash->h3, hash->h4, hash->h5);
+ sprintf((char*)out_stream, "%016"PRIx64"%016"PRIx64"%016"PRIx64"%016"PRIx64"%016"PRIx64"%016"PRIx64, hash->h0, hash->h1, hash->h2, hash->h3, hash->h4, hash->h5);
/*sprintf((char*)out_stream, "%s%016llx", out_stream, hash->h1);
sprintf((char*)out_stream, "%s%016llx", out_stream, hash->h2);
sprintf((char*)out_stream, "%s%016llx", out_stream, hash->h3);
diff --git a/src/hash/spookyhash.c b/src/hash/spookyhash.c
index abc3ea0..1ad3003 100644
--- a/src/hash/spookyhash.c
+++ b/src/hash/spookyhash.c
@@ -1,4 +1,3 @@
-#include "../util.h"
#include "../crypto.h"
#include <stdint.h>
#include <string.h>
diff --git a/src/hash/xxh.c b/src/hash/xxh.c
index 052db3f..3fd213c 100644
--- a/src/hash/xxh.c
+++ b/src/hash/xxh.c
@@ -1,6 +1,7 @@
#include "../crypto.h"
#include <stdio.h>
#include <stdint.h>
+#include <inttypes.h>
#define max_buffer_size32 16
#define max_buffer_size64 32
@@ -129,7 +130,7 @@ int l_xxh64(lua_State* L){
char digest[64];
uint64_t u = i_xxhash64(a, seed, len);
- sprintf(digest,"%016llx",u);
+ sprintf(digest,"%016"PRIx64,u);
lua_pushstring(L, digest);
return 1;