|
|
|
<!--
This script encrypts and stores the message in the encrypted form in the database.
This can also be implemented as a function.
Be sure to Change the queries according to the fields in ur databse. But itz mandatory to include
the ivec field which is the ini vector for the encryption algorithm.
The backend CREATE is as follows:
| CREATE TABLE `messenc` (
`uid` text NOT NULL,
`dom` text NOT NULL,
`ext` text NOT NULL,
`encmess` longtext NOT NULL,
`ekey` text NOT NULL,
`iv` varchar(100) NOT NULL default '',
) TYPE=InnoDB; | |
Variable Docs:
$ekey is the encryption key given by user
$to - Is the mail id ex:veevakan
Anybody having problems with this script can mail me with the correct error message.
Put the subject line as "MessEncrypt :Bug Mail "
My @ is : veevakan@email.com
The class implementation for all the databases is on itz way
| <HTML>
<TITLE>
Text Encrypted
</title>
<body text="Lucida Console" size="4">
<?
$key=$ekey;
$add=$to;
$domai=$dom;
$exte=$ext;
$ciph=$cipher;
print($ciph);//DEBUG LINE
$iv = mcrypt_create_iv (mcrypt_get_iv_size (MCRYPT_RIJNDAEL_256,MCRYPT_MODE_ECB), MCRYPT_RAND);// gets the initialization vector for MCRYPT_RIJNDAEL_256 algorithm .for more algorithms look refer the PHP Manual.
$cryptext=mcrypt_encrypt (MCRYPT_RIJNDAEL_256,$key, $ta1, MCRYPT_MODE_ECB, $iv); //The message is encrypted here
$connect=mysql_connect("127.0.0.1", "uname","mysqlpassword");
mysql_select_db("user_reg"); //This is the database which contains the messenc table
if($connect!=0)
{
$query="SELECT encmess FROM messenc WHERE uid='$add' and dom='$domai' and ext='$exte' and ekey='$key'";
$res = mysql_query($query); //Checks whether the message already exists in the table
if($res)
{
$row=mysql_fetch_assoc($res);
if(mysql_num_rows($res)>0)
{
$ecmess=$row["encmess"]
if(strcmp($ecmess,$cryptext)!=0) // Checks the message from table and the encrypted message
{
$query1="INSERT INTO messenc(uid,dom,ext,encmess,ekey,ivec)"." VALUES('$add','$domai','$exte',"."'$cryptext','$key','$iv')"; // If the message is new ,then inserted into table
$quok=mysql_query($query1);
if($quok!=false)
{
print("<BR><BR> Done");
print($iv);
}
else
{
print("Error during DB operations");
}
}
else
{
print("<BR><B>Message11 already inserted</b><BR>"); //DEBUG LINE
}
}
else
{
print("<BR><B>Message12 already inserted</b><BR>");//DEBUG LINE
}
}
else
{
print("Couldn't connect to DSN1");
}
}
?> | |
</body>
</html>
|
|
| This program allows you to upload an ODBC ressource - i.e. an MS-Access database to a MySQL server. Categories : Databases, MySQL, Complete Programs, PHP, Databases | | | bookmarker - PHP, PHPLIB, MySQL WWW based bookmark manager Categories : MySQL, PHP, MySQL, Complete Programs, Databases | | | A login page that require username, password and userlevel. Categories : PHP, Security, Sessions, MySQL, Databases | | | Accepts a database & hostname from a user and then HTTP username and password. Uses this to connect to a MySQL database. Produces a form based on the tables it finds there to allow the user to do SELECTs, INSERTs, and DELETEs. Categories : Databases, PHP, MySQL, Complete Programs | | | phpAds, a complete banner and ad management system with detailled tracking and stats. Categories : MySQL, Complete Programs, Ecommerce, PHP, Databases | | | Point and Click Interface ala MS Access for creating SQL statements. Categories : MySQL, Complete Programs, General SQL, PHP, Databases | | | Message of the Day - Random Message (Needs MySQL!) Categories : Databases, HTML and PHP, PHP, MySQL | | | Alternating background color for HTML table rows Categories : PHP, Databases, MySQL, HTML and PHP | | | color codes for positive and negative numbers Categories : PHP, MySQL, Databases, HTML | | | Authorize Me! An authentication script. Categories : MySQL, Databases, Authentication, PHP | | | A very simple way to build and do a hierarchical html categories browser without javascript , just using html php and mySql
Categories : HTML and PHP, Databases, Algorithms, PHP, MySQL | | | Tropicalm Genetree Family (MySQL based family tree) Categories : PHP, Interfaces, Databases, MySQL, Complete Programs | | | mysql_escape_string Categories : PHP, MySQL, Databases, Strings | | | Automatically printing the contents of an sql table in MySQL. Categories : MySQL, PHP, HTML and PHP, Databases | | | Email a user with out exposing email address Categories : PHP, Databases, MySQL, Email | |
|
|
|