ورود

View Full Version : رمزنگاری AES در C++



sezar21m
شنبه 03 مهر 1395, 22:42 عصر
سلام به همه
نیاز شدید به یک مثال آماده از الگوریتم رمزنگاری AES در زبان ++C داشتم ممنون میشم راهنمایی فرمایید

negative60
یک شنبه 04 مهر 1395, 01:19 صبح
میتونی‌ از کتاب خونه‌های ++Crypto (http://www.cryptopp.com/wiki/Advanced_Encryption_Standard) یا OpenSSL (https://wiki.openssl.org/index.php/EVP_Symmetric_Encryption_and_Decryption) یا libressl و ... استفاده کنی‌

T.R.G.T
یک شنبه 04 مهر 1395, 11:47 صبح
142759





#include <openssl/aes.h> #include <stdlib.h> #include <string.h> #include <stdio.h>

int main() {
char * key = "khbl654156"; char * text="hello world!"; unsigned char * enc; unsigned char * dec; AES_KEY aesEncKey,aesDecKey;


//**Encryption** enc=(unsigned char *)malloc(strlen(text)); //AES setting 256-bit encryption key AES_set_encrypt_key((unsigned char*)key, 256, &aesEncKey); //AES encrypting AES_encrypt((unsigned char*)text, enc, &aesEncKey);


//**Decryption** dec=(unsigned char *)malloc(strlen((char*)enc)); //AES setting 256-bit decryption key AES_set_decrypt_key((unsigned char*)key,256,&aesDecKey); //AES decrypting AES_decrypt(enc, dec, &aesDecKey);


printf("Text:%s\n\n",text);
printf("Encrypted:%s\n\n",enc);
printf("Decrypted:%s\n\n",dec);
getchar(); return 0; }