void DES_string_to_key(const char *str, DES_cblock *key)
{
    DES_key_schedule ks;
    int i, length;
    register unsigned char j;

    memset(key, 0, 8);
    length = strlen(str);
#ifdef OLD_STR_TO_KEY
    for (i = 0; i < length; i++)
        (*key)[i % 8] ^= (str[i] << 1);
#else                           /* MIT COMPATIBLE */
    for (i = 0; i < length; i++) {
        j = str[i];
        if ((i % 16) < 8)
            (*key)[i % 8] ^= (j << 1);
        else {
            /* Reverse the bit order 05/05/92 eay */
            j = ((j << 4) & 0xf0) | ((j >> 4) & 0x0f);
            j = ((j << 2) & 0xcc) | ((j >> 2) & 0x33);
            j = ((j << 1) & 0xaa) | ((j >> 1) & 0x55);
            (*key)[7 - (i % 8)] ^= j;
        }
    }
#endif
    DES_set_odd_parity(key);
#ifdef EXPERIMENTAL_STR_TO_STRONG_KEY
    if (DES_is_weak_key(key))
        (*key)[7] ^= 0xF0;
    DES_set_key(key, &ks);
#else
    DES_set_key_unchecked(key, &ks);
#endif
    DES_cbc_cksum((const unsigned char *)str, key, length, &ks, key);
    OPENSSL_cleanse(&ks, sizeof(ks));
    DES_set_odd_parity(key);
}