Hi!
Been working all day trying to copy this multidimensional array to a single dimensional array. Everytime I try I either get a segmentation fault or it tries to access some wierd memory stuff
Here's the code if you'd like to check it. It is using OpenSSL to hash a text so don't mind the OpenSSL code (I know that part is working)
Code:
char *EncryptString(const char *encryption, const char *string) {
EVP_MD_CTX mdctx;
const EVP_MD *md;
unsigned char mdv[EVP_MAX_MD_SIZE];
int md_len;
OpenSSL_add_all_digests();
md = EVP_get_digestbyname(encryption);
EVP_MD_CTX_init(&mdctx);
EVP_DigestInit_ex(&mdctx, md, NULL);
EVP_DigestUpdate(&mdctx, string, strlen(string));
EVP_DigestFinal_ex(&mdctx, mdv, &md_len);
EVP_MD_CTX_cleanup(&mdctx);
char mdv_temp[255][5];
char r_string[512];
int i=0;
for(i=0;i<md_len;i++) {
sprintf(mdv_temp[i],"%02x",mdv[i]);
}
for(i=0;i<255;i++) {
r_string[i] = mdv_temp[i];
}
}
What i want to know is if there is any cool (read: good) way to do this (You are free to tell me how) and/or what I am doing wrong.