2025-08-05 14:06:07 -07:00
|
|
|
import waku/waku_core
|
2025-11-20 16:02:57 -08:00
|
|
|
import std/[macros, times]
|
2025-07-05 14:54:19 -07:00
|
|
|
import blake2
|
2025-07-14 19:39:21 -07:00
|
|
|
import strutils
|
2025-08-05 14:06:07 -07:00
|
|
|
|
2025-09-05 15:35:47 -07:00
|
|
|
proc getCurrentTimestamp*(): Timestamp =
|
2025-08-05 14:06:07 -07:00
|
|
|
result = waku_core.getNanosecondTime(getTime().toUnix())
|
2025-07-05 14:54:19 -07:00
|
|
|
|
2025-09-05 15:35:47 -07:00
|
|
|
proc hash_func*(s: string | seq[byte]): string =
|
2025-07-11 15:43:19 -07:00
|
|
|
# This should be Blake2s but it does not exist so substituting with Blake2b
|
|
|
|
|
result = getBlake2b(s, 4, "")
|
|
|
|
|
|
2025-07-16 16:17:22 -07:00
|
|
|
proc bytesToHex*[T](bytes: openarray[T], lowercase: bool = false): string =
|
|
|
|
|
## Convert bytes to hex string with case option
|
|
|
|
|
result = ""
|
|
|
|
|
for b in bytes:
|
|
|
|
|
let hex = b.toHex(2)
|
|
|
|
|
result.add(if lowercase: hex.toLower() else: hex)
|