I wrote a DES encryption module for the xDev magazine, Issue 20.2 (March/April 2022), and the algorithm would work well in most situations and would fail in a few circumstances.

When Xojo converts a number that contains zeros in front of it, these zeros are deleted. Which is good in most circumstances, but not good in DES Encryption.

Take the following correct DES sequence of numbers. Notice the fourth set of numbers begins with 0acdb.

5A94632308D6C29B 77E4EB4797868B1A 40D2081A2AB5005A 0acdb3c06e4ae914  b4510ce260db0c04

The code that I created in Xojo has the fourth set of number that begins with the number acdb, and the zero is missing.

5A94632308D6C29B 77E4EB4797868B1A 40D2081A2AB5005A acdb3c06e4ae914  b4510ce260db0c04

To correct this issue, the DESEncrypt method has an added While-Wend loop to ensure the zeros are added:

Var Tmp as String = c.ToHex
While Tmp.Length < 16
Tmp = “0” + Tmp
Wend
Final = Final + Tmp 

 

Each portion of numeric output has 16 digits and extra zeros are added when the calculated number is small.

Here is the final working program that can be downloaded: DES Encryption (Xojo 2022 r1.1)