|
there are plenty of algorithms out there
I suggest you have a look at the source code for the compresion algorithm used in crypto++, you may also wish to do a search of 'zip' and 'zlib' etc on google as there are a lot of freeware (source code provided) implementations (though most algorithms of any note are patented and are protected by law)
Technically speaking the dictionary would define Visual Basic users as programmers. But here again, a very generalized, liberal definition is being employed and it's wrong - just plain wrong - Tom Archer 5/12/02
|
|
|
|
|
Hi !
I try to use your code but i can't solve this problem. I use MFC 7 .NET
I use this code.
USING_NAMESPACE( CryptoPP )
Gzip zipper; //(1) 1 is fast, 9 is slow
zipper.Put(byteOrgTest, nFileSize);
zipper.Close(); // error ?
byte* pCompressed = new byte[zipper.MaxRetrieveable()]; //error ?
zipper.Get(pCompressed,zipper.MaxRetrieveable()); //error ?
error C2039: 'Close' : is not a member of 'CryptoPP::Gzip'
error C2039: 'MaxRetrieveable' : is not a member of 'CryptoPP::Gzip'
As far as i can see Close is a member of Gzip??
Can you please help me? Why do I get this error message? 'error C2039:'
Thank's
|
|
|
|
|
Have you downloaded the latest crypto++ library from http://www.cryptoppp.com? The file on codeproject is probably a bit old.
Technically speaking the dictionary would define Visual Basic users as programmers. But here again, a very generalized, liberal definition is being employed and it's wrong - just plain wrong - Tom Archer 5/12/02
|
|
|
|
|
Yes I have downloaded the latest crypto++ "Crypto++5.1.zip" library from http://www.cryptopp.com? I downloaded it again and tryed the new software but i still got the same problem. I try to compile Dialogbased MFC project but that chould not be a problem?
|
|
|
|
|
Looked a bit further looks like they have altered the Gzip library since 4.1 to which this article was written against.
you ned to
#define CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY
Technically speaking the dictionary would define Visual Basic users as programmers. But here again, a very generalized, liberal definition is being employed and it's wrong - just plain wrong - Tom Archer 5/12/02
|
|
|
|
|
I inserted this first in my file #define CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY
but i still got the same problem?? I would wery much like to use this Gzip class
so if you can help me I would appreciate it very much.
|
|
|
|
|
well you can always use the new functions instead - for Close() its MessageEnd()
and for MaxRetrieveable() its MaxRetrievable() - they fixed the typo
I found these by searching the files
Technically speaking the dictionary would define Visual Basic users as programmers. But here again, a very generalized, liberal definition is being employed and it's wrong - just plain wrong - Tom Archer 5/12/02
|
|
|
|
|
Trying to get this thing to build in an MFC project under MSVC6? Do you think, gosh, maybe this *could* be simpler? Look no further! It's as easy as 1-2-K-aardvark-{backspace}-quark-3!
First of all, you apparently have to #define CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY to even begin to get the code to compile. Then if you look in cryptlib.h, you'll see five typedef's starting at line 1555 - put a semi-colon at the end of each line, the way Kernigan intended. Honestly, the compiler can be so *picky*.
Now, assuming you said "USING_NAMESPACE(CryptoPP)" before the declaration of "zipper" - you *did* do that, didn't you? - it should compile under MSVC6. Golly, only half an hour wasted (of my time, not yours, gentle reader).
Now you can start trying to get it to link. Looks like it needs CryptLib.cpp, so add that to your project. Now you'll get "fatal error C1010: unexpected end of file while looking for precompiled header directive". Just turn off pre-compiled headers in your project's settings for now. Bloody nuisance anyway.
Now it needs GZip.cpp. Do I have to add every frigging CPP and H file to my project to get this to compile?!? I guess this isn't the elegent solution I was hoping for. But let's add all the CPP files - oops, now I get "fatal error C1076: compiler limit"! No problem, just add the compiler switch "/Zm1000" and rebuild.
Okay, now I only get 25 linker errors like "socketft.obj : error LNK2001: unresolved external symbol __imp__WSAGetOverlappedResult@20". Well, let's hunt... looks like I need to link in "Ws2_32.lib". I guess the author forgot to mention that. Just say, "#pragma comment (lib, "Ws2_32.lib")".
Yea! It links. Now lets implement decompress, and see if I get the same bytes out that I put in! It works. Now all I have to do is see if I can pare it down to under 250 CPP and H files...
Spaghetthi Rustler
|
|
|
|
|
LarryLeonard wrote:
First of all, you apparently have to #define CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY to even begin to get the code to compile.
really - never had to do that myself
LarryLeonard wrote:
Now, assuming you said "USING_NAMESPACE(CryptoPP)" before the declaration of "zipper" - you *did* do that, didn't you? - it should compile under MSVC6. Golly, only half an hour wasted (of my time, not yours, gentle reader).
well you could waste a day writing it yourself and I believe we covered the namespace issue earlier
LarryLeonard wrote:
Now you can start trying to get it to link. Looks like it needs CryptLib.cpp, so add that to your project. Now you'll get "fatal error C1010: unexpected end of file while looking for precompiled header directive". Just turn off pre-compiled headers in your project's settings for now. Bloody nuisance anyway.
well that is the fault of visual studio and anybody who has used that environment soon knows about that one.
LarryLeonard wrote:
Okay, now I only get 25 linker errors like "socketft.obj : error LNK2001: unresolved external symbol __imp__WSAGetOverlappedResult@20". Well, let's hunt... looks like I need to link in "Ws2_32.lib". I guess the author forgot to mention that. Just say, "#pragma comment (lib, "Ws2_32.lib")".
errm - what sockets - I don't remember mentioning sockets.
LarryLeonard wrote:
Yea! It links. Now lets implement decompress, and see if I get the same bytes out that I put in! It works. Now all I have to do is see if I can pare it down to under 250 CPP and H files...
why - I build it as a static library then the compiler just takes what it needs when it links.
LarryLeonard wrote:
Spaghetthi Rustler
ah a cowboy - makes sense now
Technically speaking the dictionary would define Visual Basic users as programmers. But here again, a very generalized, liberal definition is being employed and it's wrong - just plain wrong - Tom Archer 5/12/02
|
|
|
|
|
Re #define CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY. I wonder if we're using different versions of the code? At any rate, if you're reading this, and can't get anything to compile, try that #define - it might work.
The namespace issue was covered in someone's post. I'm just saying it would be nice if it could find its way into the article.
I understand that the pre-compiled header thing is the "fault" of Visual Studio (they'd call it a feature). I was just annoyed that instead of writing down the steps someone would need to take to get it to compile, I get to hack through it for a few hours, especially as it was billed as being "simple".
I don't remember anything about sockets, either, but if you want the thing to link, you have to include the header.
I don't *want* to build it as a static library - that may suit your purposes, but it doesn't suit mine. I posted this to help anyone else down the road in a similar boat.
Despite the tedium-induced typo, I think of the American cowboy as an honorable profession. Cowboys worked long, hard days, under little direct supervision, hewed to their own code of honor, spent years perfecting their skills, and took great pride in their work. The insulting sense of "cowboy", as a reckless hip-shooter, which you are using, is not what I meant.
|
|
|
|
|
LarryLeonard wrote:
Re #define CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY. I wonder if we're using different versions of the code? At any rate, if you're reading this, and can't get anything to compile, try that #define - it might work.
we are - this article was written against 4.1 and the latest is 5.1 that define is new
LarryLeonard wrote:
I don't remember anything about sockets, either, but if you want the thing to link, you have to include the header.
well if you are going to rock the boat and not use the predefined projects that come with the library then yes you will have to build the library from scratch and that includes defing all its dependancies
LarryLeonard wrote:
I don't *want* to build it as a static library - that may suit your purposes, but it doesn't suit mine. I posted this to help anyone else down the road in a similar boat.
why? I am sorry but people do get very confused about static libraries - when you link against a static library you do *not* get the whole library linked in as well only those parts that you use so it is quite efficient. It save a lot of hassle trying to split the files apart and you have the advantage that if you want to use something else from the library it's already to hand.
Technically speaking the dictionary would define Visual Basic users as programmers. But here again, a very generalized, liberal definition is being employed and it's wrong - just plain wrong - Tom Archer 5/12/02
|
|
|
|
|
Geez, in those 279 files in the ZIP file, I didn't even *see* the two DSP files. You might want to mention their existance in your article - who knew they were even there?? This is what I'm talking about: just a little more detail in your article would make it 100 times more useful.
(And yes, some people do get confused by statically linked libraries. I fully understand them, and have written and used them for over a decade, but in this case, they simply do not fit my purpose: I don't *want* to link against a static library. It's not an efficiency issue. I'm sure other people might find themselves in a similar situation someday.)
|
|
|
|
|
Doesn't compile in Visual C++ 7.0
|
|
|
|
|
you may need to get the latest library from www.cryptocpp.com[^]
Technically speaking the dictionary would define Visual Basic users as programmers. But here again, a very generalized, liberal definition is being employed and it's wrong - just plain wrong - Tom Archer 5/12/02
|
|
|
|
|
hi, im having trouble using this library...
im uing M VC++ 6.0 on Win 98,
can any one provide me step by step instructions to use this library
Thanx
|
|
|
|
|
what problems are you having?
Stupidity dies.
The end of future offspring.
Evolution wins.
- A Darwin Awards Haiku
|
|
|
|
|
Well, if i am to use this library in my work space in a dialog based application to zip and unzip a file
how would i accomplish this.
I've tried to follow the readme file but that doesnt work...
|
|
|
|
|
if you are on about .zip files then I don't think it will work - as a .zip file isn't just one compressed file but many files bundled together - you will have to look at the .zip file spec for that
Stupidity dies.
The end of future offspring.
Evolution wins.
- A Darwin Awards Haiku
|
|
|
|
|
hi ,
I've tested your code , but the return pointer contains nothing . if i save returned buffer to file the file size would be 0 , why ?
B.Regards
|
|
|
|
|
|
Hi ,
I just load a file to buffer like:
CFile file ;
file.Open("Original.BMP",CFile::modeRead);
int len = file.Read(buffer , file.getLength());
file.Close();
then I tried zip :
#include "Gzip.h"
# ....
// by the way , i need to include many head files to pass the compile (must i build the project in the same directory of crypto or the new project refuse to work ? )
Gzip zipper;
zipper.Put(buffer,len);
zipper.Close();
byte* pCompressed = new byte[zipper.MaxRetrieveable()];
// in debug i can see the return value of zipper.MaxRetrieveable() is valid but the last get function returns containing nothing
zipper.Get(pCompressed,zipper.MaxRetrieveable());
file.Open(...);
file.Write((byte*)buffer , zipper.MaxRetrieveable());
file.Close()
the new file size is always to be zero
i use vc6 with sp5 under win98 osr2 .
I can send u a small piece of real code if necessary .
thanks & best regards
You can also reply to my private mail address
zoushen@21cn.com
thanks !
|
|
|
|
|
Hi ,
I just load a file and compress it like
BYTE* buffer = NULL;
CFile file ;
file.open("aa.doc" , CFile::modeRead);
buffer = new BYTE[file.getlength()];
int len = file.read(buffer , file.getlength());
file.Close();
Gzip zipper ;
zipper.Put(buffer,len);
zipper.Close();
byte* pCompressed = new byte[zipper.MaxRetrieveable()];
zipper.Get(pCompressed,zipper.MaxRetrieveable());
file.open("zipped.zip",CFile::modecreate|CFile::modeWrite);
file.write((BYTE*)pCompressed , zipper.MaxRetrieveable());
file.Close();
// the size of zipped.zip is always to be Zero
By the way , i must copy many head files to new project and include gzip.h .
I'm using vc6 + sp5 under win2k + sp2 + crypto 4.1
thanks and best regards
|
|
|
|
|
no your code does not work
>byte* pCompressed = new byte[zipper.MaxRetrieveable()]; // MaxRetrievable returns size of compressed data available to be got
>zipper.Get(pCompressed,zipper.MaxRetrieveable()); // ditto
>file.open("zipped.zip",CFile::modecreate|CFile::modeWrite);
>file.write((BYTE*)pCompressed , zipper.MaxRetrieveable()); // fault here - MaxRetrievable now returns 0 as you have got the data
>file.Close();
try this
long nLen=zipper.MaxRetrieveable();
byte* pCompressed = new byte[nLen];
zipper.Get(pCompressed,nLen);
file.open("zipped.zip",CFile::modecreate|CFile::modeWrite);
file.write((BYTE*)pCompressed , nLen);
file.Close();
A simple step though using the debugger would have shown what was happening
Holy Handgrenade of Antioch instructions
|
|
|
|
|
hi ,
I've tested your code , but the return pointer contains nothing . if i save returned buffer to file the file size would be 0 , why ?
B.Regards
|
|
|
|
|
Hi!
Your line
Gzip zipper(1);
just resulted in following error while compiling your code with the crypto++ 4.1 lib:
CryptoPP::Gzip(class CryptoPP::BufferedTransformation *,unsigned int,unsigned int)' : not possible to convert 'const int' in 'class
CryptoPP::BufferedTransformation *'
And when I check the source of gzip.h, there is just one constructor:
Gzip(BufferedTransformation *outQ=NULL, unsigned int deflateLevel=DEFAULT_DEFLATE_LEVEL, unsigned int log2WindowSize=DEFAULT_LOG2_WINDOW_SIZE);
Do I have a wrong library?
Bye, Wilfried
|
|
|
|
|