prime Posted February 3, 2008 Share Posted February 3, 2008 Hi trying to encrypt a little chat box thing I have as some of the stuff being discussed is somewhat confidential, I'm trying to store this in the database in aes encryption, not sure exactly whats going wrong, but all the data appears to be going in blank. the program works fine without aes, so I know the rest of the program is good, just not the encrypting and decrypting bit insert code <?php include('sessioncall.inc'); ?><html><head></head><body bgcolor="darkblue"> <?php $chat_submitted = $_POST['chatenter']; if($chat_submitted == "TRUE") { $chat = $_POST['chat']; $host="*****"; $user="*****"; $password="*****"; $database="*****"; $connection = mysql_connect($host,$user,$password) or die("couldn't connect toserver"); $db = mysql_select_db($database,$connection) or die("couldn't select database"); $query = "INSERT INTO ***** (primename, comments) VALUES ('$name', (AES_ENCRYPT('$chat', '*****' )))"; $result = mysql_query($query) or die("couldn't execute query"); } ?> <form action="<?php echo "$this_file"; ?>" method="post"> <input type="hidden" name="chatenter" value="TRUE"> <center><input name="chat" type="text" size="35"></center> </form> </body></html> reader code <?php include('sessioncall.inc'); $display = 10; ?> <?php $chat_username = ucfirst(strtolower($_SESSION['username'])); ?> <html><head > <META HTTP-EQUIV="refresh" content="8;URL=<?php echo "$this_file"; ?>"> </head><body bgcolor="black"><font color="white"> <?php $host="*****"; $user="*****"; $password="*****"; $database="*****"; $connection = mysql_connect($host,$user,$password) or die("couldn't connect toserver"); $db = mysql_select_db($database,$connection) or die("couldn't select database"); $query = "Select user_id, primename, (AES_DECRYPT('comments','*****')) from ***** order by user_id DESC LIMIT $display"; $result = mysql_query($query) or die("couldn't execute query"); while ($row = mysql_fetch_array($result)) { extract($row); echo "<b>$primename</b>: $comments<br />"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/89117-aes-encrpytion/ Share on other sites More sharing options...
prime Posted February 3, 2008 Author Share Posted February 3, 2008 ok from what I am seeing the the information is being stored good, just seems to be the decryption stage Quote Link to comment https://forums.phpfreaks.com/topic/89117-aes-encrpytion/#findComment-456473 Share on other sites More sharing options...
trq Posted February 3, 2008 Share Posted February 3, 2008 Try... <?php $query = "SELECT user_id, primename, (AES_DECRYPT('comments','*****')) AS comment FROM ***** ORDER BY user_id DESC LIMIT $display"; $result = mysql_query($query) or die("couldn't execute query"); while ($row = mysql_fetch_array($result)) { extract($row); echo "<b>$primename</b>: $comment<br />"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/89117-aes-encrpytion/#findComment-456497 Share on other sites More sharing options...
prime Posted February 3, 2008 Author Share Posted February 3, 2008 Still coming back blank Quote Link to comment https://forums.phpfreaks.com/topic/89117-aes-encrpytion/#findComment-456541 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.