C++ help for Encryption to generate CVC
CipherAnil <[email protected]>
| Newsgroups | gmane.comp.encryption.cryptlib |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I am trying to generate a Dynamic CVC(Card Verification Code) number for a
digital Card using 3DES algorithm. To generate the CVC i need to use a
standard key and encrypt a data like
[0D 14 00 00 08 99 00 5E] sample data(8 byte).
Can anybody post a sample code on how to encrypt it as ASAP.:confused:
Post my sample code.
::Encrypt(CString Key, CString Data, CString *Cryptogram)
{
int rc,len,copied=0;
int nTemp = -1;
nTemp = cryptInit();
char unsigned Buffer[1000];
memset(Buffer,0x00,1000);
memcpy(Buffer,(LPCTSTR)Data,Data.GetLength());
len = (int)strlen((char *)Buffer);
CRYPT_ENVELOPE cryptEnvelope;
rc=cryptCreateEnvelope( &cryptEnvelope, CRYPT_UNUSED, CRYPT_FORMAT_CRYPTLIB
);
rc=cryptSetAttribute( cryptEnvelope,
CRYPT_OPTION_ENCR_ALGO,CRYPT_ALGO_3DES);
cryptSetAttribute( cryptEnvelope, CRYPT_ATTRIBUTE_BUFFERSIZE, 90000L );
cryptSetAttributeString( cryptEnvelope, CRYPT_ENVINFO_PASSWORD,
Key.LockBuffer(), Key.GetLength());
rc=cryptSetAttribute( cryptEnvelope, CRYPT_ENVINFO_DATASIZE,
Data.GetLength());
rc=cryptPushData( cryptEnvelope, Buffer, len, &copied );
rc=cryptFlushData( cryptEnvelope);
memset(Buffer,0x00,1000);
cryptPopData( cryptEnvelope, Buffer, 1000, &copied);
*Cryptogram=ByteToHexString(&Buffer[0],copied);
cryptDestroyEnvelope( cryptEnvelope );
Key.ReleaseBuffer();
Anil
--
View this message in context: http://www.nabble.com/C%2B%2B-help-for-Encryption-to-generate-CVC-tp24894617p24894617.html
Sent from the Cryptlib mailing list archive at Nabble.com.
_______________________________________________
Cryptlib mailing list
[email protected] via Mail: [email protected]
Archive: ftp://ftp.franken.de/pub/crypt/cryptlib/archives/
http://news.gmane.org/gmane.comp.encryption.cryptlib
Posts from non-subscribed addresses are blocked to prevent spam, please
subscribe in order to post messages.