2

I am trying to implement IDEA algorithm in C#, just to learn how it works. I have taken a 128 bit binary key and generated the 52 encryption keys using the following code:

static ushort[] getKeys(string binaryKey)
{
        ushort[] keys = new ushort[52];
        int index = 0;
        while (true)
        {
            int bitPos = 0;
            keys[index++] = Convert.ToUInt16(binaryKey.Substring(bitPos, 16), 2);
            bitPos += 16;
            keys[index++] = Convert.ToUInt16(binaryKey.Substring(bitPos, 16), 2);
            bitPos += 16;
            keys[index++] = Convert.ToUInt16(binaryKey.Substring(bitPos, 16), 2);
            bitPos += 16;
            keys[index++] = Convert.ToUInt16(binaryKey.Substring(bitPos, 16), 2);
            bitPos += 16;
            if (index == 52)
                break;
            keys[index++] = Convert.ToUInt16(binaryKey.Substring(bitPos, 16), 2);
            bitPos += 16;
            keys[index++] = Convert.ToUInt16(binaryKey.Substring(bitPos, 16), 2);
            bitPos += 16;
            keys[index++] = Convert.ToUInt16(binaryKey.Substring(bitPos, 16), 2);
            bitPos += 16;
            keys[index++] = Convert.ToUInt16(binaryKey.Substring(bitPos, 16), 2);
            bitPos += 16;
            binaryKey = binaryKey.Substring(25) + binaryKey.Substring(0, 25);
        }
        return keys;
}

but now I cannot understand how to get those decryption keys. I couldn't find enough text on the matter too.

0 Answers0