PHP generates different random keys for the OPS host.

Source: Internet
Author: User

<?phpclass 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 ');//  password generator function Public function generator_pass () {$time  = time ();//$MD 5 ($string); MD5 The   function can also generate a random value for a string $string =  $time  .  "[email protected]#$%^&"; $string 1 =  str_shuffle ($string);  //$password  = chunk_split ($string 1,9);  inserts a specified string in the 9th position $ Password = mb_substr ($string 1,0,12);return  $password//var_dump ($string 1. " \ n ");//var_dump ($password." \ n ");}   Generate a password for the host and log 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);? >

Python writing habits, writing PHP or some not used to it!! Contact us! Enjoy!!

This article is from the "Bobo Road" blog, please be sure to keep this source http://shiyiguo.blog.51cto.com/4949751/1900351

PHP generates different random keys for the OPS host.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.