Binary Encryption

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Im using md5 to encrypt and decrypt plain text, this works fine...

When i try to run the same function on a binary file, it does not
decrypt correctly.   Is there a way to encrypt binary files correctly,
and be able to decrypt them?

in the perfect situation i would like to be able to store the
encrypted binary file into a mysql blob field, or at least be able to
save an encrypted version of the binary file on the server.

Im not lookign for a copy paste soultion (although i would take one) -
but maybe some reliable documention or examples?


Re: Binary Encryption

 .oO(Phil Palmieri)

Quoted text here. Click to load it


Quoted text here. Click to load it

MD5 is a hash algorithm, which is not reversible by definition. In other
words: You can't decrypt a hash.

Quoted text here. Click to load it

In most cases it's better to store binary data in real files. Storing it
as BLOBs in a database will probably slow down the db server and make
queries inefficient.

Anyway, you might want to have a look at Mcrypt.

PHP's Encryption Functionality [page 3]


Re: Binary Encryption

Ok, maybe i didnt explain that well...  

Irregardless of what im using, im encrypting a string so..  "Phil" +
"password(s)" becomes "#sakdhk3hk34s2"; (not real i just typed
gibbrish); and then can be reversed.

forget the database for now, --  If i run my encryption function on
the contents of a ASCII file (using fopen) i can encrypt and decrypt
it fine, so i tried with my fingers crossed to see if it would work on
a binary file --  it didn't.

So, Pretending im starting from scratch, how would i encrypt a binary
file? and then be able to decrypt it using a 'password'.

So FILE + "password" = 'garbage'
and garbage + "password" = FILE

If i cant nativly do it in PHP, is there Server based software i can
install and just run cron system commands?


Quoted text here. Click to load it

Re: Binary Encryption

How can it be irregardless of encryption method?
You're probably not using a binary-safe encryption method.

If that's the case, Base64 encode your binary file, then encrypt that.
When decrypting, just remember to base64 decode the output.

Phil Palmieri wrote:
Quoted text here. Click to load it

Site Timeline