My boss needs me to embed the MD5 digest in a file path, but the problem is MD5 contains escape characters.I've already taught about a uc%duc%d... format, but it also makes lengthy file names. In Linux it's not a problem since the Linux kernel could handle them.char * uc_encode_md5(const char * password){  char digest_output[1024];  MD5_CTX md5_ctx ;  MD5_Init(&md5_ctx);  MD5_Update(&md5_ctx,password,strlen(password));  MD5_Final((unsigned char*) digest_output,&md5_ctx);  char* ret = (char*) malloc(500);  int len=0;  int i ;  for(i=0;i<16;i++)  {   len+= sprintf(&ret[len],uc%d,(unsigned char)digest_output[i]);   }  return ret;}Any better way than this? Since my just boss shared what to do, but not how to do it: what's the best practice here?How about #ifdef's?  I could suggest more formats on here and let him choose when I get back to him later tonight.For example:char * uc_encode_md5(const char * password){#ifdef _UC_PATH_ENCODE_  char digest_output[1024];  MD5_CTX md5_ctx ;  MD5_Init(&md5_ctx);  MD5_Update(&md5_ctx,password,strlen(password));  MD5_Final((unsigned char*) digest_output,&md5_ctx);  char* ret = (char*) malloc(500);  int len=0;  int i ;  for(i=0;i<16;i++)  {   len+= sprintf(&ret[len],uc%d,(unsigned char)digest_output[i]);   }#endif /* endif _UC_PATH_ENCODE_ */  return ret;}
Embed MD5 digest in a directory path name
c;cryptography