Crypto++ is a C++ class library of cryptographic algorithms and schemes written by Wei Dai. For more information about this library, visit their official website or wiki.
Crypto++ library is allocated and ready to use at cryptopp/cryptopp.
The following example shows how to encrypt a message with SHA1 code.
Start a new project and copy the code below:
$ bii init cryptopp_example -L
$ cd cryptopp_example
$ # Create main_cryptopp.cpp
$ # Copy the code
main_crypto.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 | #include "sha.h"
#include "filters.h"
#include "hex.h"
#include <iostream>
#include <string>
int main() {
CryptoPP::SHA1 sha1;
std::string source = "Hello"; //This will be randomly generated somehow
std::string hash = "";
CryptoPP::StringSource(source, true, new CryptoPP::HashFilter(sha1, new CryptoPP::HexEncoder(new CryptoPP::StringSink(hash))));
std::cout << hash;
}
|
Check the dependencies of the project with bii deps:
$ bii deps
INFO: Processing changes...
your_user/cryptopp depends on:
system:
iostream
string
unresolved:
filters.h
hex.h
sha.h
Edit the biicode.conf file generated in the project folder. Add your [requirements]
depending on the version you want and map your [includes]
:
[requirements]
cryptopp/cryptopp: 8
[includes]
*.h: cryptopp/cryptopp
Check again with bii deps to show all dependencies are now resolved.
Now, build and run the encryption code.
$ bii build
$ cd bin
$ # run executable
F7FF9E8B7BB2E09B70935A5D785E0CC5D9D0ABF0
You can find this example in the biicode crypto samples block. See how it works in a few steps here.
Create a project:
$ bii init cryptopp_example
$ cd cryptopp_example
$ bii open examples/cryptopp
You will see next console output after executing the command:
$ ./bin/examples_cryptopp_main_crypto
F7FF9E8B7BB2E09B70935A5D785E0CC5D9D0ABF0