You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
information-system/application/controllers/encryption.php

55 lines
1.8 KiB
PHP

<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
class Encryption extends CI_Controller {
function __construct() {
parent::__construct();
//$this->output->enable_profiler(TRUE);
$this->load->model('mail_accounts_model');
}
public function index() {
$data = array();
//随机几次,让随机因子滚动一下
$this->make_password(8);
$this->make_password(12);
$this->make_password(10);
$data['password'] = $this->make_password(12);
//$this->load->view('bootstrap/header' );
$show = $this->input->get('show');
if ($show == 'true') {
//$data['low_list'] = $this->mail_accounts_model->get_list();
}
$this->load->view('bootstrap/encryption', $data);
//$this->load->view('bootstrap/footer');
}
public function make_password($length = 8) {
// 密码字符集,可任意添加你需要的字符
$chars = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D',
'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '!',
'@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '_',
'[', ']', '{', '}', '<', '>', '~', '`', '+', '=', ',',
'.', ';', ':', '/', '?', '|');
// 在 $chars 中随机取 $length 个数组元素键名
$keys = array_rand($chars, $length);
$password = '';
for ($i = 0; $i < $length; $i++) {
// 将 $length 个数组元素连接成字符串
$password .= $chars[$keys[$i]];
}
return $password;
}
}