Initial import.
[salza2.git] / checksum.lisp
blobc5bfc9a11c9dc0c06daa1af1f9305bc7b5d0463c
1 ;;;; $Id: checksum.lisp,v 1.2 2007/12/20 16:32:00 xach Exp $
3 (in-package #:salza2)
5 (defclass checksum () ())
7 (defgeneric update (checksum buffer start count)
8 (:documentation "Update the CHECKSUM object with COUNT octets
9 from BUFFER, starting from START."))
11 (defgeneric result (checksum)
12 (:documentation "Return the result of CHECKSUM as an integer."))
14 (defgeneric result-octets (checksum)
15 (:documentation "Return the result of CHECKSUM as a list of
16 octets, in MSB order."))
18 (defun ub32-octets (result)
19 (list (ldb (byte 8 24) result)
20 (ldb (byte 8 16) result)
21 (ldb (byte 8 8) result)
22 (ldb (byte 8 0) result)))