mcrypt has - or rather had - the nasty habit of padding anything with zeros if the size isn't correct. Even worse, it also cuts keys to the correct size by removing bytes.
As squeamish ossifrage commented mcrypt only seems to support 3 key triple DES. That's not that bad, until you notice that it will happily accept a 2 key triple DES key of 16 bytes, and then pad it with zeros to make it a 3 key triple DES key. It should of course fail, and newer versions of mcrypt should actually do so.
You can create the same result using 3 key triple DES though. 2 key triple DES simply reuses the first key for the last key, so copying the first 8 bytes and appending it to the end of the key will get you the right result (again, as squeamish already noted).
Better use another crypto library to get right results. mcrypt (the underlying C library) hasn't been maintained for 8 years or so (and counting) and is crappy as hell.
Example in Java (which also doesn't support 2 key triple DES fully):
byte[] pt = new byte[16];
SecretKeyFactory fact = SecretKeyFactory.getInstance("DESede");
Cipher desEDE = Cipher.getInstance("DESede/ECB/NoPadding");
{
// usual 2-key triple DES:
byte[] keyData = Hex.decode("112233445566778811223344556677881122334455667788");
SecretKey generatedSecret = fact.generateSecret(new SecretKeySpec(keyData, "DESede"));
desEDE.init(Cipher.ENCRYPT_MODE, generatedSecret);
byte[] ct = desEDE.doFinal(pt);
System.out.println(Hex.toHexString(ct)); // result: 6FB23EAD0534752B
}
{
// "zero padded" 2-key triple DES:
byte[] keyData = Hex.decode("112233445566778811223344556677880000000000000000");
SecretKey generatedSecret = fact.generateSecret(new SecretKeySpec(keyData, "DESede"));
desEDE.init(Cipher.ENCRYPT_MODE, generatedSecret);
byte[] ct = desEDE.doFinal(pt);
System.out.println(Hex.toHexString(ct)); // result: 8ca64de9c1b123a7
}
Notes:
- your DES keys are not fully valid as the parity bits of each byte is not correctly set (those, however, are not used in the DES calculations);
- better use AES and an authenticated cipher mode rather than the insecure ECB mode.