RE: CryptoAPI TripleDes

From: Rhett Gong [MSFT] (v-raygon_at_online.microsoft.com)
Date: 07/06/05


Date: Wed, 06 Jul 2005 09:10:47 GMT

Hi,
In our doc and internal sites, there is no existing sample which describes
the use of 3des alg to encrypt string with pure c-style crypto interface.
It should not that complicated as you image, you just need to create a
random bytes (eg 8bytes) and appended to the front of the plaintext. then
you can get the key by calling CryptGenKey or CryptDeriveKey with CALG_3DES
as rc2. Please note that, to use 3des alg, you need to specify
MS_ENHANCED_PROV when calling CryptAcquireContext.

Fortunately, we have an encapsulated .net class named TripleDES which
encapsulate complexity of using 3des and provides a direct way to encrypt a
stream. You may take a look at following page, it provide a simple sample
code to encrypt a file:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemsecuritycryptographytripledesclasstopic.asp

Please let me know if my answer helps you resolve the problem. If there is
anything more I can assist you, please feel free to let me know.

Thanks,
Rhett Gong [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties and confers no rights.