From 860792f1f3ead7d7509ea652eaabdcbb8f329cc5 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Sat, 21 Mar 2015 07:16:49 +0100 Subject: Update untracked file --- Untracked/main.cpp.untracked | 216 ------------------------------------------- 1 file changed, 216 deletions(-) delete mode 100644 Untracked/main.cpp.untracked (limited to 'Untracked/main.cpp.untracked') diff --git a/Untracked/main.cpp.untracked b/Untracked/main.cpp.untracked deleted file mode 100644 index bfcb75e..0000000 --- a/Untracked/main.cpp.untracked +++ /dev/null @@ -1,216 +0,0 @@ -#include -#include - -//#include "crypto++/HASHCrypt.hpp" - -#include -#include - -#include -using CryptoPP::HexEncoder; -using CryptoPP::HexDecoder; - -#include -using CryptoPP::BufferedTransformation; -using CryptoPP::AuthenticatedSymmetricCipher; - -#include -using CryptoPP::SecByteBlock; - -#include -using CryptoPP::CFB_Mode; - -#include -using CryptoPP::StringSink; -using CryptoPP::StringSource; -using CryptoPP::AuthenticatedEncryptionFilter; -using CryptoPP::AuthenticatedDecryptionFilter; - - - -#include -using CryptoPP::AutoSeededRandomPool; - -#include -using CryptoPP::AES; - -#include - - -#include -using CryptoPP::GCM; -using CryptoPP::GCM_TablesOption; - - - - - -void getKI(std::string chaine,byte* key, byte* iv, int size){ - - - - - CryptoPP::MD5 hash; -byte digest[ CryptoPP::MD5::DIGESTSIZE ]; -std::string message = chaine; - - -hash.CalculateDigest( digest, (byte*) message.c_str(), message.length() ); - - -CryptoPP::HexEncoder encoder; -std::string output; -encoder.Attach( new CryptoPP::StringSink( output ) ); -encoder.Put( digest, sizeof(digest) ); -encoder.MessageEnd(); - - - - for(int i=0; i::Encryption* enc = new CFB_Mode::Encryption(key, size, iv, 1); - - -// the final argument is specific to CFB mode, and specifies the refeeding size in bytes. This invocation corresponds to Java's Cipher.getInstance("AES/CFB8/NoPadding") -CryptoPP::CFB_Mode::Decryption* dec = new CFB_Mode::Decryption(key, size, iv, 1); - - - - - -} - - -void aff(std::string chaine); -//#include "crypto++/sha3.h" -int main(){ - -/* /home/loic/Documents/c/forgetIt/crypto++/HASHCrypt.cpp|21aff("------------------\n"); - - HASHCrypt monhash=HASHCrypt("loic"); - aff(monhash.getMD5_128()); - aff("\n"); - - aff("--------------\n");*/ - - - std::string MessageS="Bonjours les amis, je vais être crypter !!!!"; - char* Message=(char*)MessageS.c_str(); - - std::cout << Message << std::endl; - - AutoSeededRandomPool rnd; - - // Generate a random key - //SecByteBlock key(0x00, AES::DEFAULT_KEYLENGTH); - //rnd.GenerateBlock( key, key.size() ); - - // Generate a random IV - //byte iv[AES::BLOCKSIZE]; - //rnd.GenerateBlock(iv, AES::BLOCKSIZE); - - - - - - - - - - - - std::string cle; - - - aff("Entrez une clé de cryptage : "); - std::cin >> cle; - - - - byte key[32]; - byte iv[32]; - - getKI(cle,key,iv, sizeof(key)); - - - - - - - int messageLen = (int)strlen(Message) + 1; - - ////////////////////////////////////////////////////////////////////////// - // Encrypt - - CFB_Mode::Encryption cfbEncryption(key, sizeof(key), iv); - cfbEncryption.ProcessData((byte*)Message, (byte*)Message, messageLen); - - - - while(not(cle=="exit")){ - byte key2[32]; - byte iv2[32]; - - - MessageS="Bonjours les amis, je vais être crypter !!!!"; - - CFB_Mode::Encryption cfbEncryption(key, sizeof(key), iv); - cfbEncryption.ProcessData((byte*)Message, (byte*)Message, messageLen); - - - aff("Entrez une clé de décryptage : "); - std::cin >> cle; - - - getKI(cle,key2,iv2, sizeof(key)); - - - ////////////////////////////////////////////////////////////////////////// - // Decrypt - - std::cout << std::endl << "Decryptage : " << std::endl; - - CFB_Mode::Decryption cfbDecryption(key2,sizeof(key2), iv2); - cfbDecryption.ProcessData((byte*)Message, (byte*)Message, messageLen); - - std::cout <