This library helps you to develop your applications in a very easy way with Crypto++. It permits a developer with a minimal understanding of C++ to rapidly use a crypting library!
My idea was to help new Crypto++ programmers to avoid using their time reading the Crypto++ manual, and adapting all Crypto++ functions to the C++ standard
Using the Code
SpaceCrypto namespace is divided into two classes:
Hash. The first one allows you to perform rapid encrypt\decrypt operations with the most common methods (AES, Twofish, DES,...) using the C++
string type (
std::string). The second one performs hashing encryption (SHA, MD5, ...).
Crypto Class Usage
Now we're ready to use the wrapper. The first thing you need to declare is an instance of the
Crypt class in the
SpaceCrypto namespace. You can use one of the predefined
typedefs that includes most of the common algorithms (AES, Blowfish, DES,..), or specify another encryption algorithm in the type name.
Note: In the last case, you need to include the library of the algorithm and specify it in the type name.
After declaring an instance of the
Crypt class, you must set the plain text, the key, and optionally the IV. The function parameters are self explanatory. Remember that you must specify the incoming
string format type (HEX or normal), or it will automatically turn into normal input. You can also specify the output type (
setInputMode and set
OutputMode). When you're ready to encrypt (or decrypt) your
string, you need to call the
Decrypt()) method. This will return you the processed
getStatus() will return a boolean value representing the current status of
true = error;
getErrorMsg() will return a
string indicating the current error message
You can only perform one encrypt\decrypt function at a time. To perform another crypt operation with the same Crypto object, you need to call the
reset() function. This is a security reason, but it has another explanation... When you call the
Encrypt function for the first time (or
obj proceeds to encrypt all data. So if you call the
Encrypt function again (to retrieve another coded
string), it doesn't call the Crypto++ crypting function again, but it will simply return the already encoded
Security advise: For this reason, I strongly recommend you to call the
reset() function immediately after the conversion, if you don't need to call other functions again, because the plain
string and the plain key will remain in the RAM until you delete the object!
Hash Class Usage
The hash function work similar to the crypto class, with some exceptions:
- Remember that hash functions are one-way, so you can't retrieve the
Hash class offers the
addStr function that allows you to add some text to the plain
Class Usage (Example)
cout<<"Space Wrapper TEST!"<<endl<<endl;
crypt = hello.Encrypt();
cout<<"Plain Text: HelloWorld!"<<endl;
cout<<"Crypt Text: "<<crypt<<endl;
cout<<"Decrypted Text: "<<hello.Decrypt()<<endl;
SpaceCrypto cannot compile without including the cryptopp libraries. So, before compiling, read the following:
- Download and extract the cryptopp libraries from here.
- Compile the cryptopp
static library by opening the "cryptlib.dsp" project, and include the generated library in your project (in the linker options).
- Insert in your project the cryptopp include folder (main directory).
- You must include cryptlib.lib in your project in order to compile your code.
- This is a simple class that helps programmers write simple code. If you need something more complex, you cannot use the class. If you need high level functionality... you must study Crypto++.
- Predef IV is initialized at "0"; if you want to change it, you can edit the
- 06/07/2010 - Added an example into the zip file, tutorial modified
- 26/06/2010 -
SpaceCrypto v.1.0.0 released
- 20/09/2010 - Updated source code