//#include <openssl/md5.h>
#include <openssl/aes.h>
#include <openssl/evp.h>
#include <stdio.h>
#include <string.h>
int main(){
unsigned char* data
= malloc(128);
size_t datalen = 0;
const char* password = "krumpli";
EVP_CIPHER_CTX encx;
unsigned char plaintext[] = "kecske\n";
//unsigned char salt[] = "nemrandom";
unsigned char salt[8];
RAND_pseudo_bytes(salt, sizeof salt);
unsigned char iv[32];
unsigned char key[32];
unsigned char* ciphertext;
int plaintext_len
= strlen(plaintext
), ciphertext_len
= 0;
EVP_BytesToKey
(EVP_aes_128_cbc
(), EVP_md5
(), salt
, password
, strlen(password
), 1, key
, iv
);
int len1, len2;
len1 = plaintext_len + AES_BLOCK_SIZE;
EVP_EncryptInit_ex(&encx, EVP_aes_128_cbc(), NULL, key, iv);
EVP_EncryptUpdate(&encx, ciphertext, &len1, plaintext, plaintext_len);
EVP_EncryptFinal(&encx, ciphertext + len1, &len2);
ciphertext_len = len1 + len2;
fwrite("Salted__", 1, 8, stdout
);
fwrite(ciphertext
, 1, ciphertext_len
, stdout
);
return 0;
}
{"text":"text","html5":"html","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"lua","bash":"sh","erlang":"erlang","go":"golang","c":"c_cpp","cpp":"c_cpp","diff":"diff","latex":"latex","sql":"sql","xml":"xml","0":"text","abap":"abap","actionscript":"actionscript","actionscript3":"actionscript","ada":"ada","apache":"apache_conf","applescript":"applescript","asm":"assembly_x86","autohotkey":"autohotkey","closure":"closure","cobol":"cobol","coffeescript":"coffee","cpp-winapi":"c_cpp","c_loadrunner":"c_cpp","c_mac":"c_cpp","c_winapi":"c_cpp","csharp":"csharp","d":"d","dart":"dart","dot":"dot","eiffel":"eiffel","fortran":"fortran","groovy":"groovy","haskell":"haskell","haxe":"haxe","ini":"ini","io":"io","java":"java","java5":"java","make":"makefile","matlab":"matlab","mysql":"mysql","objc":"objectivec","ocaml":"ocaml","pascal":"pascal","perl":"perl","perl6":"perl","postgresql":"pgsql","powershell":"powershell","prolog":"prolog","properties":"properties","rails":"ruby","rust":"rust","scala":"scala","scheme":"scheme","smarty":"smarty","tcl":"tcl","vala":"vala","vb":"vbscript","verilog":"verilog","vhdl":"vhdl","yaml":"yaml"}