summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/std/sha1.nim4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/std/sha1.nim b/lib/std/sha1.nim
index bda0c6de7..3cc8a0249 100644
--- a/lib/std/sha1.nim
+++ b/lib/std/sha1.nim
@@ -275,3 +275,7 @@ proc `==`*(a, b: SecureHash): bool =
 
   # Not a constant-time comparison, but that's acceptable in this context
   Sha1Digest(a) == Sha1Digest(b)
+
+proc isValidSha1Hash*(s: string): bool =
+  ## Checks if a string is a valid sha1 hash sum.
+  s.len == 40 and allCharsInSet(s, HexDigits)