Tim Droz,您好!
I have test this code . but errors are :
D:\test\crypt\crypt.cpp(40) : error C2664:
'StreamTransformationFilter::StreamTransformationFilter' : cannot convert parameter 3
from 'const int' to 'enum CryptoPP::StreamTransformationFilter::BlockPaddingScheme'
Conversion to enumeration type requires an explicit cast (static_cast, C-style
cast or function-style cast)
D:\test\crypt\crypt.cpp(51) : error C2664:
'StreamTransformationFilter::StreamTransformationFilter' : cannot convert parameter 3
from 'const int' to 'enum CryptoPP::StreamTransformationFilter::BlockPaddingScheme'
Conversion to enumeration type requires an explicit cast (static_cast, C-style
cast or function-style cast)
Error executing cl.exe.
Creating browse info file...
crypt.exe - 2 error(s), 0 warning(s)
======= 2003-08-03 20:42:00 您在来信中写道:=======
>Yeah this sample is great,for a newby this kind of
>sample / documentation would be nice.
>
>I'm trying to do DUKPT simulation with crypto++ I'm
>not sure of this library and its applicability.
>Any more help would be really appreciated.
>
>
>Thanks again David
>Tim
>
>--- "David C. Partridge" <[EMAIL PROTECTED]>
>wrote:
>> Do you mean like:
>> #include "default.h"
>> #include "des.h"
>>
>> #include <iostream>
>> #include <time.h>
>>
>> #include <windows.h>
>>
>> #if (_MSC_VER >= 1000)
>> #include <crtdbg.h> // for the debug heap
>> #endif
>>
>> USING_NAMESPACE(CryptoPP)
>> USING_NAMESPACE(std)
>>
>>
>> int main()
>> {
>> // Note the for ECB, the PlainText and Cipher Text
>> MUST be an EXACT multiple
>> // of the cipher blocksize
>> byte plaintext[48] = {'H','e','l','l','o','
>> ','W','o','r','l','d','\0'};
>> byte * ciphertext;
>> byte * result;
>> byte key[DES::DEFAULT_KEYLENGTH];
>>
>> // initialize key and iv here
>> memcpy(key, "12345678", sizeof(key));
>>
>>
>> // encrypt
>> ECB_Mode<DES>::Encryption ecbEncryption;
>> ecbEncryption.SetKey(key,
>> ecbEncryption.DefaultKeyLength());
>> StreamTransformationFilter
>> encryptor(ecbEncryption, NULL, NULL);
>> encryptor.Put(plaintext, sizeof(plaintext));
>> encryptor.MessageEnd();
>>
>> unsigned int outputLength =
>> encryptor.MaxRetrievable();
>> ciphertext = new byte[outputLength];
>> encryptor.Get(ciphertext, outputLength);
>>
>> // now decrypt
>> ECB_Mode<DES>::Decryption ecbDecryption;
>> ecbDecryption.SetKey(key,
>> ecbDecryption.DefaultKeyLength());
>> StreamTransformationFilter
>> decryptor(ecbDecryption, NULL, NULL);
>> decryptor.Put(ciphertext, outputLength);
>> decryptor.MessageEnd();
>>
>> outputLength = decryptor.MaxRetrievable();
>> result = new byte[outputLength];
>> decryptor.Get(result, outputLength);
>>
>> cout << "recovered plaintext is " << result
>> << endl;
>>
>> delete [] ciphertext;
>> delete [] result;
>> return 0;
>> }
>>
>>
>
>
>__________________________________
>Do you Yahoo!?
>Yahoo! SiteBuilder - Free, easy-to-use web site design software
>http://sitebuilder.yahoo.com
>
>.
= = = = = = = = = = = = = = = = = = = =
致
礼!
forest
[EMAIL PROTECTED]
2003-08-04