您好,登錄后才能下訂單哦!
這篇文章主要為大家展示了“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如何為運維主機生成不同的隨機秘鑰”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。