Commit bd97225341b50e8f74f3b695f6f034190dde6faa

Thomas de Grivel 2024-10-28T14:34:38

wip crypt

diff --git a/.ikc3_history b/.ikc3_history
index 1bf8cd2..e01afd5 100644
--- a/.ikc3_history
+++ b/.ikc3_history
@@ -1,6 +1,3 @@
-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 = ?]]
 %HTTP.Request{}
 quote %HTTP.Request{}
@@ -97,3 +94,6 @@ Str.size(Str.random_base64(1))
 Crypt.sha512_hash_password("Plop")
 Str.random_base64(64)
 Crypt.sha512_hash_password("Plop")
+Crypt.sha512("Plop", "$6$rounds=1234567$abc0123456789$")
+Crypt.sha512("Plop", "$6$rounds=123456$abc0123456789$")
+Crypt.sha512_hash_password("Plop")
diff --git a/lib/kc3/0.1/crypt.kc3 b/lib/kc3/0.1/crypt.kc3
index 786b6a9..6ead892 100644
--- a/lib/kc3/0.1/crypt.kc3
+++ b/lib/kc3/0.1/crypt.kc3
@@ -7,13 +7,13 @@ defmodule Crypt do
 
   def sha512 = cfn Str "crypt_sha512" (Str, Str, Result)
 
+  def sha512_check_password = fn (password, hash) {
+    hash == sha512(password, hash)
+  }
+
   def sha512_hash_password = fn (password) {
     salt = Str.random_base64(16)
     sha512(password, "$6$rounds=123456$#{salt}$")
   }
 
-  def sha512_check_password = fn (password, hash) {
-    hash == sha512(password, hash)
-  }
-
 end