Page 1 of 1

Encrypting values

Posted: Tue Mar 09, 2004 5:37 am
by dakkonz
How can i encode and decode my values to be stored inside the Mysql database?? I get an error call to undefined function when i used AES_ENCRYPT or ENCODE().....
How is the code to be writter??

Posted: Tue Mar 09, 2004 5:41 am
by twigletmac
How are you using the code which is not working?

Mac

Posted: Tue Mar 09, 2004 6:33 pm
by dakkonz

Code: Select all

$query = "INSERT INTO song (songname) VALUES (ENCODE('$sn'))";
	$result = @mysql_query ($query);
Is this correct??

thanks

Posted: Tue Mar 09, 2004 8:44 pm
by partiallynothing
I have not heard of an 'encode' function, although there may be, but one i do know of is 'password', but i would not recommend it. When you do it the way you are, you are sending the information unencrypted (or un-hashed) and then mySQL does the hashing. To encode the string before it is sent, use something like MD5 hashing. Here is an example:

Code: Select all

<?php
$my_hashed_string = md5($my_unhashed_string);

$query = "INSERT INTO song (songname) VALUES ('$my_hashed_string')";
?>

Posted: Wed Mar 10, 2004 3:39 am
by malcolmboston
encrypt and decrypt, not as secure as MD5 but can be reversed back into plain text unlike MD5

Posted: Wed Mar 10, 2004 9:31 am
by dull1554
or you could make some crazy function to encrypt with

Code: Select all

function crypto($str)
{
    $str = crypt($str);
    $str = md5($str);
    $str = md5($str);
    $str = "9Fq5tG3".$str."GT9c8XkkwWal58p";
    return $str;
}

Posted: Wed Mar 10, 2004 1:27 pm
by Weirdan
dull, it's much easier to decrypt the string encrypted twice =)

Posted: Wed Mar 10, 2004 2:06 pm
by dull1554
i know that but rather then decrypting when you want to compare an excrtpted string to a non encrypted one all you have to do is use the same func to encrypt the non encrypted one then compare them.....

Posted: Thu Mar 11, 2004 8:10 am
by dakkonz
kz will try it out and get back to here....thanks