crypto++

Get hexadecimal encrypted string in AES 256 Crypto++

喜欢而已 提交于 2019-12-02 07:19:41
I am trying to implement the AES 256 algorithm using Crypto++ in MS visual studio. Operating system is Windows 7 (64 bit). I need to provide the key as a hexadecimal string, password as string and finally i want the encrypted string to also be hexadecimal string. Here is what I am trying to do: My encrypt method: std::string encrypt(const std::string &password) { std::string plain = password; std::string ciphertext; char * decodedKey= "729308A8E815F6A46EB3A8AE6D5463CA7B64A0E2E11BC26A68106FC7697E727E37011"; byte key[ CryptoPP::AES::MAX_KEYLENGTH ], iv[ CryptoPP::AES::BLOCKSIZE ]; CryptoPP:

How to loop over Blowfish Crypto++

こ雲淡風輕ζ 提交于 2019-12-02 04:25:27
I am running Crypto++ doing speed tests on encryption algorithms. I am trying to time how long it takes to encrypt, then decrypt the data(eventually with more file sizes and different algorithms). I am running into a problem where I cannot loop over the code. In the following code, I am using Blowfish, but when I get to the encryption part, it gives me the error: HashVerificationFilter: message hash or MAC not valid What can I do to fix this? Do I need to put it in a function? If so, how would I do that? /** * g++ encryption_tests.cpp -o encryption_tests -lcryptopp -lpthread -L. */ #include

AES padding and writing the ciphertext to a disk file

怎甘沉沦 提交于 2019-12-02 03:51:09
问题 I have a string which I encrypt with the following mehtod in C++ using Crypto++: std::ifstream t(filename); //File to be encrypt std::stringstream buffer; buffer << t.rdbuf(); ofstream combined_file2(filename2); //Encrypted file combined_file2 << encrypt(buffer.str()); string encrypt(string data) { // Key and IV setup std::string key = "0123456789abcdef"; std::string iv = "aaaaaaaaaaaaaaaa"; //Alternative //byte key[CryptoPP::AES::DEFAULT_KEYLENGTH], iv[CryptoPP::AES::BLOCKSIZE]; //memset(key

Saving Crypto++ objects to std::vector

做~自己de王妃 提交于 2019-12-02 03:07:58
问题 I want to save Crypto++ keys to std::vector<uint8_t> . Unfortunately there is only CryptoPP::StringSink , that takes std::string reference but no CryptoPP::VectorSink that would take a reference to std::vector . Following code works fine std::string spki; CryptoPP::StringSink ss(spki); CryptoPP::RSA::PublicKey publicKey(...); publicKey.Save(ss); But I want this std::vector<uint8_t> spki; CryptoPP::VectorSink vs(spki); CryptoPP::RSA::PublicKey publicKey(...); publicKey.Save(vs); The problem

AES padding and writing the ciphertext to a disk file

半腔热情 提交于 2019-12-02 02:05:29
I have a string which I encrypt with the following mehtod in C++ using Crypto++: std::ifstream t(filename); //File to be encrypt std::stringstream buffer; buffer << t.rdbuf(); ofstream combined_file2(filename2); //Encrypted file combined_file2 << encrypt(buffer.str()); string encrypt(string data) { // Key and IV setup std::string key = "0123456789abcdef"; std::string iv = "aaaaaaaaaaaaaaaa"; //Alternative //byte key[CryptoPP::AES::DEFAULT_KEYLENGTH], iv[CryptoPP::AES::BLOCKSIZE]; //memset(key, 0x00, CryptoPP::AES::DEFAULT_KEYLENGTH); //memset(iv, 0x00, CryptoPP::AES::BLOCKSIZE); std::string

How to change the include file path with autotools?

只谈情不闲聊 提交于 2019-12-02 01:19:58
问题 I am developing a simple chat application, which use crypto++, in ubuntu. The folder for crypto++'s header files is /usr/include/crypto++/ . After I upload the source tagbar to CentOS , I found that the folder for crypto++'s header files is /usr/include/cryptopp . So in CentOS , the compiler could not find the head files for cryptopp . Source File: #include "crypto++/md5.h" Configure.ac: AC_SEARCH_LIBS([_ZTIN8CryptoPP14CBC_EncryptionE], [crypto++ cryptopp], [],[AC_MSG_ERROR([avchat requires

What's the difference between templated mode object and external cipher object?

☆樱花仙子☆ 提交于 2019-12-02 01:15:29
As in the title, I am looking for the difference in the cryptopp library between this declaration: CBC_Mode<AES>::Decryption cbcDecryption.SetKeyWithIV(key, AES::DEFAULT_KEYLENGTH, iv); and this one: AES::Decryption aesDecryption(key, AES::DEFAULT_KEYLENGTH); CBC_Mode_ExternalCipher::Decryption cbcDecryption( aesDecryption, iv ); Moreover, I can't understand why with this: AES::Decryption aesDecryption(key, AES::DEFAULT_KEYLENGTH); CBC_Mode_ExternalCipher::Decryption cbcDecryption( aesDecryption, iv ); StreamTransformationFilter stfDecryptor( cbcDecryption, new StringSink( recoveredtext ) );

Saving Crypto++ objects to std::vector

我的梦境 提交于 2019-12-01 23:17:31
I want to save Crypto++ keys to std::vector<uint8_t> . Unfortunately there is only CryptoPP::StringSink , that takes std::string reference but no CryptoPP::VectorSink that would take a reference to std::vector . Following code works fine std::string spki; CryptoPP::StringSink ss(spki); CryptoPP::RSA::PublicKey publicKey(...); publicKey.Save(ss); But I want this std::vector<uint8_t> spki; CryptoPP::VectorSink vs(spki); CryptoPP::RSA::PublicKey publicKey(...); publicKey.Save(vs); The problem VectorSink can not be created just by using a typedef because of traits_type::char_type inside

encrypt-decrypt single block with AES and Crypto++

十年热恋 提交于 2019-12-01 22:27:55
I need to encrypt single block of AES. I cant use any modes like CBC and other. Every example what i have seen use streaming modes. EDIT: ok, i did it in the next manner, but i really dislike this try. void dec(const byte *key, const byte* xblock, const byte *cipher, byte *plain) { AESDecryption d; try { const NameValuePairs &nvp = MakeParameters("", 0); d.UncheckedSetKey(key, 16, nvp); d.ProcessAndXorBlock(cipher, xblock, plain); } catch(...) {} } AES in ECB mode is identical to single block encryption, except that you can feed it multiple blocks. If you've got only CBC mode encryption

TripleDES in CFB mode, C# and Crypto++ differs

旧时模样 提交于 2019-12-01 21:46:32
Here is my problem: I've got a legacy code in C++ (using crypto++ v5.6.1) and I develop a new one in C# (.NET 3.5 using System.Security.Cryptography). I can't change the C++ code, but I need to be able to decrypt data previously encrypted and previous applications has to be able to decrypt the data I will crypt with my new C# code. The algorithm used is TripleDES with CFB cipher mode in both cases, but in the end, the encrypted data are not the same, the number of bytes are identical as well as the first byte, but apart from that all other bytes are different. The padding is manually done