Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

encryption 1

Status
Not open for further replies.

TheConeHead

Programmer
Aug 14, 2002
2,106
US
Is it possible encrypt data in mySQL/PHP? if so, how do you encrypt/decrypt?

[conehead]
 
Yes, you can encrypt any kind of data in MySQL/PHP...

If you go to and put encryption in the search box, and change functions to whole site, the first hit will be the mcrypt functions which allow for reversible encryption.

Beyond that there are several other things you can do, i.e. if you're storing passwords, one way encryption is generally easier and safer.
 
can anyone help more better understand the purpose of the $key in encrypting? Is this just a string, and if it always the same, I should be ok?

Thanks

[conehead]
 
The easiest way to encrypt anything is just using md5(), and a few other functions.

For example, you can find the md5() hash of a string, reverse it, and use some custom functions to encrypt it even further.

md5(strrev($string));
 
md5() doesn't encrypt, but hashes, but its still safe enough to use to encrypt passwords.

I just made a nice little function that will switch the characters of a string around a bit.

"123456" will become "214365"
"1234567" will become "2143657"

The function is called switchstr()

So.. If you use switchstr(strrev(md5($password))); to encrypt each password, then the 32-bit code that a hacker can find wont be of any use. I made this because I still write and keep passwords in text files and not MySQL, and there are too many XSS exploits that can make a hacker view the md5() hash of a password.


If you want me to post the function, I will.
 
The poster actually wanted something that first encrypts and then later decrypts. MD5 is a one way conversion.
However, thanks you for your contributions!
 
Anything that can be easily decrypted isn't secure. Plus.. You can work with md5() hashes.

if (md5($form_password) == $encrypted_pass) {
block
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top