473,386 Members | 2,042 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Binary Encryption

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?

Thanks,
Phil
Jul 17 '05 #1
3 10375
.oO(Phil Palmieri)
Im using md5 to encrypt and decrypt plain text, this works fine...
Huh?
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?
MD5 is a hash algorithm, which is not reversible by definition. In other
words: You can't decrypt a hash.
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.


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.

http://www.php.net/mcrypt

PHP's Encryption Functionality [page 3]
http://www.onlamp.com/pub/a/php/2001...pt.html?page=3

Micha
Jul 17 '05 #2
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?

Thanks,
PHil
Michael Fesser <ne*****@gmx.net> wrote in message news:<1j********************************@4ax.com>. ..
.oO(Phil Palmieri)
Im using md5 to encrypt and decrypt plain text, this works fine...


Huh?
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?


MD5 is a hash algorithm, which is not reversible by definition. In other
words: You can't decrypt a hash.
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.


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.

http://www.php.net/mcrypt

PHP's Encryption Functionality [page 3]
http://www.onlamp.com/pub/a/php/2001...pt.html?page=3

Micha

Jul 17 '05 #3
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:
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?

Thanks,
PHil
Michael Fesser <ne*****@gmx.net> wrote in message news:<1j********************************@4ax.com>. ..
.oO(Phil Palmieri)

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


Huh?

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?


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

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.


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.

http://www.php.net/mcrypt

PHP's Encryption Functionality [page 3]
http://www.onlamp.com/pub/a/php/2001...pt.html?page=3

Micha

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: chris | last post by:
I'm writing a small app to help me learn more about cryptography. All it does is encrypt all of the files in directory A, and put the encrypted versions of the files in directory B. It then...
7
by: Niyazi | last post by:
Hi, I developed an application and I am using SQL Server 2000 developer edition. I create my database and I have also created tbl_USER table. I have an ID, RealName, UserName, and UserPassword...
7
by: Golan | last post by:
Hi, I need to convert a Binary value to Decimal. I've been told that the value is an unsigned one. How can I do this? I use memcpy into an unsigned char variable, but when I print the value I got...
1
by: Pete | last post by:
I'm trying to a very simple encryption key generator. I have hard coded a 10 binary string into an array, I then want to permute that string using another array with element of type int for 1 to...
5
by: TomB | last post by:
Anyone know of an example/tutorial for encrypting a binary file? I'm able to encrypt/decrypt simple text files, but anything more complicated craps out. Thanks TomB
3
by: Benny Ng | last post by:
Dear all, The following is the source. The password is encrypted and saved into the Binary in SQL2K. Now I want to create a new page to compare the existed password and the password that in the...
4
by: Bob Cummings | last post by:
Good Day I would like to write a password to a binary file. I am following along in the book and examples I have found googling. However when I open the file in notepad it looks like a text...
29
by: Harlin Seritt | last post by:
Hi... I would like to take a string like 'supercalifragilisticexpialidocius' and write it to a file in binary forms -- this way a user cannot read the string in case they were try to open in...
6
by: aagarwal8 | last post by:
Hi, I am trying to write the contents of a textbox to a file in binary format. My code looks like this... private void btnWriteToFile_Click(object sender, EventArgs e) { FileStream fs =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.