?
Solved

Encrypt file using crypto++

Posted on 2005-04-01
15
Medium Priority
?
1,155 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
15 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

762 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