1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| #include <iostream>
#include<fstream>
#include <stdlib.h>
#include<string.h>
#include <stdio.h>
#include<vector>
#include <openssl/evp.h>
#include <openssl/aes.h>
using namespace std;
int tex (const char fi[]);
void enc();
int main(){
string ch ="hhhhhh.bdd";
const char *chh= ch.c_str();
cout<<tex(chh)<<endl;
return 0;
}
int tex (const char fi[]){
string hh[]={".mp3",".jpeg",".txt",".py",".bdd"};
char *p ;
p = strrchr(fi, '.');
int r =0;
for(int i (0);i<5;i++){
if(!strcmp(p, hh[i].c_str())) r=1;
}
return r;
}
void enc()
{
int bytes_read, bytes_written;
unsigned char indata[AES_BLOCK_SIZE];
unsigned char outdata[AES_BLOCK_SIZE];
/* ckey and ivec are the two 128-bits keys necesary to
en- and recrypt your data. Note that ckey can be
192 or 256 bits as well */
const unsigned char ckey[] = "thiskeyisverybad";
unsigned char ivec[] = "dontusethisinput";
FILE *ifp = fopen("C:\\Users\\Animalx\\Desktop\\Nouveau dossier\\Visual Studio 2017 (2).exe", "rb");
FILE *ofp = fopen("C:\\Users\\Animalx\\Desktop\\Nouveau dossier\\output_file.enc", "wb");
/* data structure that contains the key itself */
AES_KEY key;
/* set the encryption key */
AES_set_encrypt_key(ckey, 128, &key);
/* set where on the 128 bit encrypted block to begin encryption*/
int num = 0;
while (1) {
bytes_read = fread(indata, 1, AES_BLOCK_SIZE, ifp);
AES_cfb128_encrypt(indata, outdata, bytes_read, &key, ivec, &num,
AES_ENCRYPT);
bytes_written = fwrite(outdata, 1, bytes_read, ofp);
if (bytes_read < AES_BLOCK_SIZE)
break;
}
} |
Partager