David Wood <dwoodjunkm...@gmail.com> added the comment:

I have not gone to the extent of comparing the direct output against what 
python gets, although it appears to be incomplete.  The following is my encrypt 
function which has been used successfully for many years in a separate c 
program, so I have high confidence in it.

char * encryptBlowfishCfb(const char * inStr, Py_ssize_t *count, char * output, 
char * encrkey) {
        MCRYPT td;
        char IV[10];
        int len, i;
        char block_buffer[512];
        time_t t;

        srand((unsigned) time(&t));
        strcpy(IV, "");
        for (i = 0 ; i < 8 ; i++ ) {
                IV[i] =  mset[(rand() % 62)];
        }
        td = mcrypt_module_open(MCRYPT_BLOWFISH, NULL, MCRYPT_CFB, NULL);
        mcrypt_generic_init(td, encrkey, strlen(encrkey), IV);
        memset(block_buffer, 0, sizeof(block_buffer));
        strcpy(block_buffer, inStr);
        i = strlen(inStr);
        mcrypt_generic(td, &block_buffer, i);
        block_buffer[i] = '\0';
        strcpy(&block_buffer[i], IV);
        mcrypt_generic_deinit(td);
        mcrypt_module_close(td);

        len = i + 8 + 1;
        memset(output, 0, 512);
        strncpy(output, block_buffer, len -1);
        *count = i + 8;

        return output;
}

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue43435>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to