I am attempting to convert a C application to python. I am having difficultiy on this particular for loop. Any ideas how I might proceede?
bool Enigma2C::encrypt(char *inString, char *outString)
{
int16 csum = 1, checksum = 0;
int16 tmpSum = 0;
int16 i = 0;
strcpy(m_keyCode, inString);
// Calculate and store 2-digit checksum.
for (i = 2; i < KEY_LENGTH; i++)
{
if (isdigit(m_keyCode[i]))
{
tmpSum = m_keyCode[i] - '0';
}
else
{
tmpSum = m_keyCode[i] - 'A';
}
csum += i + tmpSum + (i * tmpSum);
printf( "DEBUG> csum: %d\n", csum );
}
csum = 100 - (csum % 100);
m_keyCode[0] = '0' + (csum % 10);
m_keyCode[1] = '0' + ((csum / 10) % 10);
printf( "DEBUG m_keyCode: %s\n", m_keyCode);