I am encrypting a string using the crypto libraries in C (using gcc in Linux). Here is what I would do:
ien = encrypt ((unsigned char*)passwd, strlen(passwd), (unsigned char*)cypher_key, (unsigned char*)cypher_salt, cypher_text);
Now if I were to print out the contents of cypher_text, it would be all garbled. I need this to be saved to a text file (it will be hashed with other things so as to be obfuscated eventually). This right now is an experiment. I need to convert this raw binary data into a hexadecimal string that is readable in any text editor.
Then, I need to convert that hexadecimal string back into raw binary so I can do this and get the original text:
decrypt(cypher_text, ien, (unsigned char*)cypher_key, (unsigned char*)cypher_salt, (unsigned char*)passwd);
Can someone please point me in the right direction on how I could accomplish this?
UPDATE A suggested link about printing hex in C isn't exactly what I am after. I am taking direct unprintable data put out by the encrypt function (not hexadecimal values in an array) and trying to convert it into a string of hexadecimal numbers and be able to convert that hex string back into it's original binary form. I hope that helps clear up some of what I'm trying to do.
I'm going to look into the idea of using base64 encoding but I can't have headers, etc. in the encoding. I'll need just a straight string.