Use arena string in hash_password
This commit is contained in:
@@ -3,8 +3,11 @@
|
|||||||
#include <sha256.h>
|
#include <sha256.h>
|
||||||
|
|
||||||
Noh_String hash_password(Noh_Arena *temp, Noh_String_View username, Noh_String_View password) {
|
Noh_String hash_password(Noh_Arena *temp, Noh_String_View username, Noh_String_View password) {
|
||||||
|
noh_arena_save(temp);
|
||||||
|
|
||||||
// Build the sha input string.
|
// Build the sha input string.
|
||||||
Noh_String input = {0};
|
Noh_String input = {0};
|
||||||
|
input.arena = temp;
|
||||||
noh_string_append_sv(&input, username);
|
noh_string_append_sv(&input, username);
|
||||||
noh_string_append_cstr(&input, "<><>");
|
noh_string_append_cstr(&input, "<><>");
|
||||||
noh_string_append_sv(&input, password);
|
noh_string_append_sv(&input, password);
|
||||||
@@ -17,7 +20,6 @@ Noh_String hash_password(Noh_Arena *temp, Noh_String_View username, Noh_String_V
|
|||||||
sha256_final(&ctx, hash);
|
sha256_final(&ctx, hash);
|
||||||
|
|
||||||
// Build the result string.
|
// Build the result string.
|
||||||
noh_arena_save(temp);
|
|
||||||
Noh_String result = {0};
|
Noh_String result = {0};
|
||||||
for (int i = 0; i < 32; i++) {
|
for (int i = 0; i < 32; i++) {
|
||||||
noh_string_append_cstr(&result, noh_arena_sprintf(temp, "%02x", hash[i]));
|
noh_string_append_cstr(&result, noh_arena_sprintf(temp, "%02x", hash[i]));
|
||||||
|
|||||||
Reference in New Issue
Block a user