From 1a5ff88f0388c460828511af7c3892b4e9e37f20 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Thu, 27 Mar 2025 15:03:08 +0100 Subject: [PATCH] minor improvements on async, crypt (allow '=' trimming of digest) --- util/async.lisp | 5 ++--- util/crypt.lisp | 8 ++++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/util/async.lisp b/util/async.lisp index b53ddbe..21c0550 100644 --- a/util/async.lisp +++ b/util/async.lisp @@ -13,9 +13,8 @@ ;;;; general definitions (eval-when (:compile-toplevel :load-toplevel :execute) - (progn - (when (not (boundp '+quit-message+)) - (defconstant +quit-message+ (gensym "QUIT"))))) + (when (not (boundp '+quit-message+)) + (defconstant +quit-message+ (gensym "QUIT")))) (defun init () (when (null lp:*kernel*) diff --git a/util/crypt.lisp b/util/crypt.lisp index 284ac30..09f6a19 100644 --- a/util/crypt.lisp +++ b/util/crypt.lisp @@ -11,8 +11,12 @@ (defun create-secret (&key (bytes 16) (scheme :uri)) (util:b64-encode (ironclad:random-data bytes) :scheme scheme)) -(defun digest (tx &key (scheme :original) (alg :sha256)) - (b64:encode-bytes (ironclad:digest-sequence alg (util:to-bytes tx)) :scheme scheme)) +(defun digest (tx &key (scheme :original) (alg :sha256) trim) + (let ((dig (b64:encode-bytes + (ironclad:digest-sequence alg (util:to-bytes tx)) :scheme scheme))) + (if trim + (str:trim-right dig :char-bag "=") + dig))) (defun sign (tx key) (let* ((binp (util:to-bytes tx))