I am in the midst of writing a wrapper around a crypto library and apparently I am either rustier at C than I thought or am missing some bit of Python C api that will make this all a lot easier.<br><br>Short version of my problem is that the various library routines expect to get keys and data as pointers to unsigned char with explicit length as an additional arg.&nbsp; This seems pretty reasonable since strings containing nulls are rather common in crypto as both input and output.
<br><br>My first thought was that things would be fairly easy in pyrex since python strings also have no problems with embedded nulls. The various crypto functions I am using are not changing the length of what is getting passed to them.&nbsp; After going through several iterations of ways I hoped I could manipulate these python strings into useful pointers to the data I wanted I am now feeling somewhat mixed up (and a bit frustrated at getting to the point where most of my tests work and some occasionally fail....)
<br><br>To assure myself that I am on the right track and get a fresh viewpoint untainted by the various ratholes I have crawled through to get to this point, does anyone have a suggestion for a good wrapper to my various input/ouput needs given a pythonic side that just takes in strings (which may contain embedded nulls like &quot;\x00this is a key&quot; or &quot;\x00\x00x00\x00&quot;) and calls a C library using the follow two functions:
<br><br>setup_crypto(unsigned char *key, int keylen)<br>do_crypto(unsigned char *input, unsigned char *output)<br><br><br>Any suggestions as the &quot;the pyrex way&quot; regarding this would be greatly appreciated.<br><br>
Regards,<br><br>Jim<br><br><br>