1 (uiop:define-package
#:lw2.hash-utils
3 (:import-from
#:flexi-streams
#:string-to-octets
#:octets-to-string
)
4 (:export
#:city-hash-128-vector
#:hash-string
#:hash-printable-object
#:hash-file-list
)
7 (in-package #:lw2.hash-utils
)
9 (defun city-hash-128-vector (data)
10 (let ((array (make-array 16 :element-type
'(unsigned-byte 8))))
11 (multiple-value-bind (r1 r2
) (city-hash:city-hash-128 data
)
12 (setf (nibbles:ub64ref
/be array
0) r1
13 (nibbles:ub64ref
/be array
8) r2
))
16 (defun hash-string (string)
17 (city-hash-128-vector (string-to-octets string
:external-format
:utf-8
)))
19 (defun hash-printable-object (object)
20 (hash-string (write-to-string object
:circle nil
:escape nil
:pretty nil
)))
22 (defun hash-file-list (file-list)
24 (with-output-to-string (out-stream)
25 (iter (for f in file-list
)
26 (with-open-file (in-stream (asdf:system-relative-pathname
:lw2-viewer f
) :direction
:input
:element-type
'character
)
27 (uiop:copy-stream-to-stream in-stream out-stream
:element-type
'character
))))))