add encrypting for save files

add libhydrogen for encrypting and decrypting

#9
This commit is contained in:
2026-04-03 14:59:37 +02:00
parent abb6556fd4
commit c277ab10d9
68 changed files with 5737 additions and 74 deletions
+22
View File
@@ -0,0 +1,22 @@
uint32_t rand_32();
static int
hydro_random_init(void)
{
const char ctx[hydro_hash_CONTEXTBYTES] = { 'h', 'y', 'd', 'r', 'o', 'P', 'R', 'G' };
hydro_hash_state st;
uint16_t ebits = 0;
hydro_hash_init(&st, ctx, NULL);
while (ebits < 256) {
uint32_t r = rand_32();
hydro_hash_update(&st, (const uint32_t *) &r, sizeof r);
ebits += 32;
}
hydro_hash_final(&st, hydro_random_context.state, sizeof hydro_random_context.state);
hydro_random_context.counter = ~LOAD64_LE(hydro_random_context.state);
return 0;
}