7 [Warning] 'int AES_set_encrypt_key(const unsigned char*, int, AES_KEY*)' is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
Como lo arreglo? porque no me lo compila:
Código:
#include <openssl/aes.h>
#include <stdio.h>
#include <string.h>
void encrypt_AES(const unsigned char *plaintext, int plaintext_len, const unsigned char *key, unsigned char *ciphertext) {
AES_KEY aes_key;
AES_set_encrypt_key(key, 128, &aes_key);
AES_encrypt(plaintext, ciphertext, &aes_key);
}
int main() {
const char *filename = "archivo.txt";
const unsigned char key[] = "clave secreta";
const int block_size = 12;
unsigned char plaintext[block_size];
unsigned char ciphertext[block_size];
// Leer el archivo de texto
FILE *file = fopen(filename, "rb");
if (file == NULL) {
printf("Error al abrir el archivo.\n");
return 1;
}
fread(plaintext, block_size, 1, file);
fclose(file);
// Cifrar el archivo de texto
encrypt_AES(plaintext, block_size, key, ciphertext);
// Escribir el archivo cifrado
FILE *output_file = fopen("archivo_cifrado.txt", "wb");
if (output_file == NULL) {
printf("Error al crear el archivo cifrado.\n");
return 1;
}
fwrite(ciphertext, block_size, 1, output_file);
fclose(output_file);
printf("Archivo cifrado exitosamente.\n");
return 0;
}
#include <stdio.h>
#include <string.h>
void encrypt_AES(const unsigned char *plaintext, int plaintext_len, const unsigned char *key, unsigned char *ciphertext) {
AES_KEY aes_key;
AES_set_encrypt_key(key, 128, &aes_key);
AES_encrypt(plaintext, ciphertext, &aes_key);
}
int main() {
const char *filename = "archivo.txt";
const unsigned char key[] = "clave secreta";
const int block_size = 12;
unsigned char plaintext[block_size];
unsigned char ciphertext[block_size];
// Leer el archivo de texto
FILE *file = fopen(filename, "rb");
if (file == NULL) {
printf("Error al abrir el archivo.\n");
return 1;
}
fread(plaintext, block_size, 1, file);
fclose(file);
// Cifrar el archivo de texto
encrypt_AES(plaintext, block_size, key, ciphertext);
// Escribir el archivo cifrado
FILE *output_file = fopen("archivo_cifrado.txt", "wb");
if (output_file == NULL) {
printf("Error al crear el archivo cifrado.\n");
return 1;
}
fwrite(ciphertext, block_size, 1, output_file);
fclose(output_file);
printf("Archivo cifrado exitosamente.\n");
return 0;
}