这篇文章主要为大家展示了“PHP如何为运维主机生成不同的随机秘钥”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“php如何为运维主机生成不同的随机秘钥”这篇文章吧
这篇文章主要为大家展示了“PHP如何为运维主机生成不同的随机秘钥”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“php如何为运维主机生成不同的随机秘钥”这篇文章吧。
<?php
class generator1 {
//const HOSTS = array(array('ubuntu'=>'123.57.221.66'),array('pay_WEB'=>'101.201.222.104'),array('video_web'=>'101.201.31.40'),array('bg_web211'=>'123.56.181.211'),array('quanzi'=>'101.201.55.37'),array('bg_web231'=>'60.205.127.231'),array('db2_master'=>'60.205.166.72'),array('db2_slave'=>'60.205.166.74'),array('db3_others'=>'59.110.11.16'),array('test_web'=>'60.205.150.53'),array('nfs1_Redis2'=>'123.57.184.167'),array('nfs1_redis1'=>'123.57.184.235'),array('zhuanfaqi'=>'123.57.185.38'),array('prepare_web'=>'59.110.8.82'),array('bg_web64'=>'10.29.130.64'));
//define("HOSTS",array('123.57.221.66','101.201.222.104','101.201.31.40','123.56.181.211','101.201.55.37','60.205.127.231','60.205.166.72','60.205.166.74','59.110.11.16','60.205.150.53','123.57.184.167','123.57.184.235','123.57.185.38','59.110.8.82','10.29.130.64'));
const HOSTS = array('123.57.203.66','101.101.222.104','102.221.51.40','112.56.131.211','121.202.45.37','101.205.127.231','101.205.166.72','63.205.166.74','39.110.13.12','65.205.150.53','33.57.134.167','123.59.104.235','148.57.135.38','59.190.8.77','10.29.130.52');
const HOSTNAMES = array('ubuntu','pay_web104','video_web40','bg_web211','quanzi37','bg_web231','db2_master72','db2_slave74','db3_others','test_web','nfs1_redis1','nfs2_redis2','zhuanfaqi','prepare_web','bg_web64');
// 密码生成器函数
public function generator_pass(){
$time = time();
//$md5($string); md5 函数也可以为字符串生成一个随机的值
$string = $time . "!@#$%^&";
$string1 = str_shuffle($string);
//$passWord = chunk_split($string1,9); 会在第9个位置插入一个指定的字符串
$password = mb_substr($string1,0,12);
return $password;
//var_dump($string1."\n");
//var_dump($password."\n");
}
// 为主机生成密码并记录日志
public function produce_pass_for_hosts(){
$new_hosts = array();
$hosts = generator1::HOSTS;
$hostnames = generator1::HOSTNAMES;
for($i=0;$i<count($hosts);$i++){
$new_hosts[$i]['hostname'] = $hostnames[$i];
$new_hosts[$i]['host'] = $hosts[$i];
$new_hosts[$i]['password'] = $this->generator_pass();
}
return $new_hosts;
}
}
$gen = new generator1();
$host_info = $gen->produce_pass_for_hosts();
var_dump($host_info);
?>
以上是“php如何为运维主机生成不同的随机秘钥”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注编程网PHP编程频道!
--结束END--
本文标题: php如何为运维主机生成不同的随机秘钥
本文链接: https://lsjlt.com/news/83697.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0