正在写的一个加密算法,社会工程学这东西很复杂,所以我在研究一下加密算法,我是用的ecshop2.73的数据库,当然现在还没完善正在研究完善中,一个加密类,期待吧兄弟们!

//类文件
<?php
	class Md5Code {
		
		private $password;
		private $username;
		private $path;
		private $salt;   
		private $dbname;
		private $table;
		
		function __construct($password, $username, $path,$dbname,$table){
			$this->password=$password;
			$this->username=$username;
			$this->path=$path;
			$this->dbname=$dbname;
			$this->table=$table;
			$this->salt=$this->getsalt();	
		}
		private function getsalt(){
			$config=include("{$this->path}");
			foreach($config as $value){
				$mysql[]=$value;
			}
			$link=mysql_connect($mysql[0],$mysql[1],$mysql[2]) or die("数据库链接失败");
			mysql_select_db("{$this->dbname}",$link);
			$result=mysql_query("SELECT `ec_salt` FROM `{$this->table}` WHERE user_name=\"{$this->username}\"",$link) or die("Invalid query: " . mysql_error());
			foreach(mysql_fetch_assoc ($result) as $value){
				$salt=$value;
			 }
			 return $salt;
		}
		function mcode(){
			$mcode=md5(md5($this->password).md5($this->username).($this->salt));
			echo $mcode;
		}
		
}
//测试文件
<?php
include ("jiami.php");
$jiami=new Md5Code("admin","admin","./config.php","xiaowei","ecs_admin_user");
$jiami->mcode();
//配置文件
<?php
return array(
	'dbhost'=>'localhost',
	'dbuser'=>'root',
	'dbpwd'=>'dgj99349',	
);
?>
这个东西还正在写的完善中等好了我会发布给大家,谢谢您对微度网络的支持,欢迎转载,转载请注明来自微度网络http://yun.widuu.com

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论
立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部