Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Encrypt file using crypto++

Posted on 2005-04-01
15
Medium Priority
?
1,371 Views
Last Modified: 2007-12-19
There are many cryptographic libraries that do that. I use crypto++ from http://www.eskimo.com/~weidai/cryptlib.html

To encrypt a file using crypto++, write:

void EncryptFile(const char *fin, const char *fout, const char
*passwd)
{
    FileSource f(fin, true, new DefaultEncryptor(passwd,
        new FileSink(fout)));
}

And to decrypt:

void DecryptFile(const char *fin, const char *fout, const char
*passwd)
{
    FileSource f(fin, false, new DefaultDecryptor(passwd,
        new FileSink(fout)));
}

I found this post and have been trying to use it to help me encorporate encryption into my project however, I have linked the .lib in my project settings and added this line of code to my source:#pragma comment ( lib, "cryptopp")
I have used the functions posted above and I still get several errors and have been forced to include a plethora of header files into my existing project.  Can anybody explain how to include this library and use those functions to simply encrypt and dexcrypt one .zip file??

Thanks, PT
0
Comment
Question by:ptrennum
  • 6
  • 5
12 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 13684646
Cryplib IMHO is overkill for that purpose, but it's your decision :o)

What errors are you getting?
0
 

Author Comment

by:ptrennum
ID: 13684694
I totally agree!! It's way over kill!!

Do you happen to have two little functions around that I could possibly use??

Thanks,

PT
0
 

Author Comment

by:ptrennum
ID: 13684738
The error I am currently getting is FileSource is unidentified.  I have included the files.h header wich has the class definitions for FileSource.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 86

Expert Comment

by:jkr
ID: 13684766
Just the links from http:Q_21371514.html - these seem to be the easiest for that purpose. There's also a sample app (with code) available from MSDN that encrypts files, but...: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncapi/html/msdn_cryptapi.asp ("The Cryptography API, or How to Keep a Secret")
0
 

Author Comment

by:ptrennum
ID: 13684823
I'm gonna need more help on this one - the encryption stuff seems a little cryptic.  Have to go now but will be working on the weekend again :(

Thanks PT
0
 
LVL 86

Expert Comment

by:jkr
ID: 13684865
>> The error I am currently getting is FileSource is unidentified

Are you using the correct namespace? I.e.

using namespace CryptoPP;
0
 

Author Comment

by:ptrennum
ID: 13697712
Yes that fixed that up but now I am getting a bunch of linker errors,


error LNK2019: unresolved external symbol "public: __thiscall CryptoPP::DefaultEncryptor::DefaultEncryptor(char const *,class CryptoPP::BufferedTransformation *)" (??0DefaultEncryptor@CryptoPP@@QAE@PBDPAVBufferedTransformation@1@@Z) referenced in function "void __stdcall EncryptZip(char const *,char const *,char const *)" (?EncryptZip@@YGXPBD00@Z)
0
 
LVL 14

Expert Comment

by:trigger-happy
ID: 13697814
chances are that you didn't specify the crypto++ library

--trigger-happy
0
 

Author Comment

by:ptrennum
ID: 13697891
I have linked to the cryptopp.lib
0
 
LVL 86

Expert Comment

by:jkr
ID: 13698640
Have you tried to add 'default.cpp' to your project?
0
 

Author Comment

by:ptrennum
ID: 13698986
I added cryptlib.lib to the settings and it compiled however now I'm getting a new error when I try to use it.  The new post is here:  
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_21375522.html

I feel that if it were to get resolved you would be entitled to the points from both questions seeing as how they're so closley related.

PT
0
 
LVL 86

Accepted Solution

by:
jkr earned 2000 total points
ID: 13700388
I'm sorry, but my knowledge about VB isn't really profound at all. I'd stick to the '__stdcall' export, since that IIRC is the default call type for VB.
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question