Plaster

common-lisp
(deftype octet () '(unsigned-byte 8)) (deftype octet-vector () '(simple-array octet (*))) (deftype index () `(integer 0 ,array-total-size-limit)) (defun make-octet-vector (len) (make-array (the index len) :element-type 'octet)) (defun pad-octet-array (arry &optional (len 32)) "Takes an octet-array and, if it is shorter than the len parameter, pads it to the len parameter by adding 0 entries at the beginning." (let ((len-arry (length arry))) (if (= len-arry len) arry (let ((initial-index (- len len-arry 1)) (oct-array (make-octet-vector len))) (loop for x across arry counting x into y do (setf (aref oct-array (+ y initial-index)) x)) oct-array)))) (pad-octet-array #(2 1 3)) #(0 0 0 0 0 0 0 0 15 0 82 0 13 0 0 0 ...) (pad-octet-array #(2 1 3)) #(0 0 0 0 0 0 0 0 1 0 91 0 32 0 5 0 ...) (pad-octet-array #(2 1 3)) #(0 0 0 0 0 0 0 0 10 0 0 0 51 0 2 0 ...)