I was asked to encrypt/decrypt a string using MACTripleDES. Is there any difference between MACTripleDES and TripleDES? If, where exactly is the difference between both?

  • $\begingroup$ You mean this thing? If so, this question on SO might be helpful. $\endgroup$ – Ilmari Karonen Jan 7 '16 at 16:24
  • $\begingroup$ thanks @IlmariKaronen, i've seen the msdn but the example showing to encrypt/decrypt the file not string. $\endgroup$ – Balaji Marimuthu Jan 7 '16 at 16:30
  • $\begingroup$ That would be a valid question on Stack Overflow, but not here. (Or you could just look at the documentation, and specifically the ComputeHash(Byte[]) method). Also, you cannot "encrypt" or "decrypt" anything with a MAC; that's not what they're for. $\endgroup$ – Ilmari Karonen Jan 7 '16 at 16:46
  • $\begingroup$ Cross-posted on Stack Overflow: How to encrypt decrypt string using MACTripleDES? $\endgroup$ – Artjom B. Jan 8 '16 at 11:40

Triple DES is a block cipher. (Specifically, it's a variant of the old DES block cipher with better security, but several times lower performance.) You can use it to encrypt small blocks of data (64 bits = 8 bytes, for Triple DES), but what it's really useful for is as a building block for other cryptographic schemes, such as stream encryption or message authentication codes (MACs).

MACTripleDES is, apparently, a class in the Microsoft .NET framework that provides some kind of a MAC using Triple DES. The documentation doesn't actually seem to say which MAC construction it uses, but this answer on SO implies that it's classic CBC-MAC.

Note that raw CBC-MAC is not, by itself, secure for variable-length messages. To make it secure, you need to use one of the techniques described in the linked Wikipedia article (prepending the length to the message, encrypting the output with a different key, or using a separate MAC key for each message length), or use a more modern MAC algorithm like CMAC instead. (You may also wish to consider using a more modern cipher with a larger key and block size and better performance than Triple DES, such AES.)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.