Jonathon McKitrick <j_mckitrick@bigfoot.com> wrote:
+---------------
| I'd like to use Ironclad for md5 hashing and http authentication. Is
| there a simple or straight-forward way to convert the string values I
| get from http into (simple-array (unsigned-byte 8) (*))?
|
| I keep thinking I've figured this out, but I'm not quite there yet.
|
| (defparameter *data* (make-array 8 :element-type :unsigned-byte
| :adjustable nil :fill-pointer nil :displaced-to nil))
| works, but
| (ironclad:update-digest *digest* *data*)
| complains that
| #(0 0 0 0 0 0 0 0) is not of type (simple-array (unsigned-byte 8) (*))
| and
| (type-of *data*) is (simple-vector 8)
| and
| (type-of (elt *data* 0)) is bit.
+---------------
The problem is probably that your MAKE-ARRAY is insufficiently-specific
to get what you need. Try executing:
(upgraded-array-element-type 'unsigned-byte)
and see what your local implementation gives you back -- probably T,
but almost certainly *NOT* (UNSIGNED-BYTE 8)!! So try this instead:
> (defparameter *data* (make-array 8 :element-type '(unsigned-byte 8)
:initial-element 0))
*DATA*
> *data*
#(0 0 0 0 0 0 0 0)
> (type-of *data*)
(SIMPLE-ARRAY (UNSIGNED-BYTE 8) (8))
> (type-of (elt *data* 0))
(INTEGER 0 0)
>
It would probably also be good to add an ":INITIAL-ELEMENT 0" to your
MAKE-ARRAY [as I did above], rather than assuming the implementation
will default it for you, since:
If initial-element is not supplied, the consequences of
later reading an uninitialized element of new-array are
undefined unless either initial-contents is supplied or
displaced-to is non-nil.
Conversely, since NIL *is* defined as the default for all of
the :ADJUSTABLE, :FILL-POINTER, & :DISPLACED-TO parameters,
you don't need to specify them here.
-Rob
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607