Commit 30f6b66903d20a07cab9ba684a36570fc2da14b5

Thomas de Grivel 2024-10-26T13:15:36

fix Str.random_base64

diff --git a/.ikc3_history b/.ikc3_history
index ea2c169..1bf8cd2 100644
--- a/.ikc3_history
+++ b/.ikc3_history
@@ -1,7 +1,4 @@
 Facts.with(db, [[KC3, :operator, op = ?], [op, :sym, sym = ?]], fn (fact) { puts("#{op} #{sym}") })
-op
-sym
-Facts.with(db, [[KC3, :operator, op = ?], [op, :sym, sym = ?]], fn (fact) { puts("#{op} #{sym}") })
 Facts.with(Facts.env_db(), [[KC3, :operator, op = ?], [op, :sym, sym = ?]], fn (fact) { puts("#{op} #{sym}") })
 Facts.with(Facts.env_db(), [[KC3, :operator, op = ?], [op, :sym, sym = ?]], fn (fact) { puts("#{inspect(op)} #{inspect(sym)}") })
 [[KC3, :operator, op = ?], [op, :sym, sym = ?]]
@@ -97,3 +94,6 @@ Str.random_base64(1)
 Str.random_base64(2)
 Str.size(Str.random_base64(2))
 Str.size(Str.random_base64(1))
+Crypt.sha512_hash_password("Plop")
+Str.random_base64(64)
+Crypt.sha512_hash_password("Plop")
diff --git a/libkc3/str.c b/libkc3/str.c
index 8c4002e..4788a9c 100644
--- a/libkc3/str.c
+++ b/libkc3/str.c
@@ -619,7 +619,7 @@ s_str * str_init_random_base64 (s_str *str, const s_tag *len)
          j < result_len) {
     u = ((random_bytes[i] << 16) +
          (random_bytes[i + 1] << 8) +
-         random_bytes[i + 2]);
+         (random_bytes[i + 2]));
     k = 0;
     while (k < 4 &&
            j < result_len) {
@@ -628,6 +628,7 @@ s_str * str_init_random_base64 (s_str *str, const s_tag *len)
       j++;
       k++;
     }
+    i += 3;
   }
   if (random_bytes_len - i == 2) {
     u = ((random_bytes[i] << 8) +