海运的博客

PHP下AES CBC/CFB 256加密

发布时间:February 3, 2017 // 分类:PHP // 1 Comment

AES CFB加解密:

<?php
$iv = substr(md5("iv"),0,16);
$encryption_key = substr(md5("key"),0,32);
echo $encryption_key."\n";
$data = 'data';
$data = openssl_encrypt($data, 'aes-256-cfb', $encryption_key, OPENSSL_RAW_DATA|OPENSSL_ZERO_PADDING, $iv);
echo bin2hex($data) . "\r\n";

$iv = substr(md5("iv"),0,16);
$data = openssl_decrypt($data, 'aes-256-cfb', $encryption_key, OPENSSL_RAW_DATA|OPENSSL_ZERO_PADDING, $iv);
echo $data . "\r\n";
?>

AES CBC加解密:

<?php
$iv = substr(md5("iv"),0,16);
$encryption_key = substr(md5("key"),0,32);
$data = 'data';
$data = openssl_encrypt($data, 'aes-256-cbc', $encryption_key, OPENSSL_RAW_DATA, $iv);
echo bin2hex($data) . "\r\n";

$iv = substr(md5("iv"),0,16);
$data = openssl_decrypt($data, 'aes-256-cbc', $encryption_key, OPENSSL_RAW_DATA, $iv);
echo $data . "\r\n";
?>

小内存生成QQ号

发布时间:July 24, 2016 // 分类:PHP // No Comments

<?php
ini_set("memory_limit","1800M");
$count = 0;
for ($i = 10000; $i <= 300000000; $i++) {
        $count++;
        $str[] = $i;
        if (($i % 100) == 0) {
                shuffle($str);
                $a = implode("\n", $str);
                $file = mt_rand(0, 10000);
                file_put_contents('data/'.$file.'.txt', $a."\n", FILE_APPEND);
                $str = array();
        }
}
for file in `ls *.txt`;do shuf $file > $file-shuf;done
cat data/*-shuf > shuf-all.txt

PHP trim数组

发布时间:October 16, 2015 // 分类:PHP // No Comments

<?php
//方法1
function trim_array($input) {
  if (!is_array($input))
    return trim($input);
  return array_map('trim_array', $input);
}
$Array = trim_array($Array);
//方法2
function trim_value (& $value ) { 
  if (!is_array($value)) {
    $value  =  trim ( $value ); 
    return;
  }
  array_walk ( $value ,  'trim_value' );
}
array_walk ($Array,  'trim_value' );

Selenium处理验证码

发布时间:September 20, 2015 // 分类:PHP,iMacros // No Comments

截取整个屏幕,获取验证码坐标及大小,然后再截取验证码:

<?php
$element = $webDriver->findElement(
  WebDriverBy::id('J-checkcode-img')
);
$element_width = $element->getSize()->getWidth();
$element_height = $element->getSize()->getHeight();
 
$element_src_x = $element->getLocation()->getX();
$element_src_y = $element->getLocation()->getY();
 
$webDriver->takeScreenshot('screenshot.png');
$src = \imagecreatefrompng('screenshot.png');
$dest = \imagecreatetruecolor($element_width, $element_height);
 
imagecopy($dest, $src, 0, 0, $element_src_x, $element_src_y, $element_width, $element_height);
imagepng($dest, './captcha.png');

PHP多多线程pthreads数据共享

发布时间:June 19, 2015 // 分类:PHP // No Comments

<?php
class sharr extends Stackable {
  public function run(){}
}

class shvar extends Stackable  {
  public $num = 1;

}

class my extends Thread {

  public function __construct($sharr, $shvar) {
    $this->sharr = $sharr; 
    $this->shvar = $shvar; 
  }

  public function run(){
    $i = 0;
    while(++$i < 10) {
      $this->sharr[]=rand(0,1000);
      $this->shvar->num++;
    }
    var_dump($this->sharr);
    var_dump($this->shvar->num);
  } 
}

$sharr = new sharr();
$shvar = new shvar();
$my = new my($sharr, $shvar);
$my->start();
$my->join();

var_dump($sharr);
var_dump($shvar->num);
?>
分类
最新文章
最近回复
  • 海运: 正常情况下编译整个内核执行make menuconfig后就不会出现此提示,当单独编译单个模块...
  • oijq: 就是用的armbian的配置文件哈,按你的教程做的,在执行make LOCALVERSION=...
  • 海运: 使用armbian的配置文件,其它添加或修改自己懂的部分,不懂的就不要碰了。
  • oijq: 编译时这些选项全部选Y吗?Actions Semi Platforms (ARCH_ACTIO...
  • 海运: n1编译bbr内核模块参考这个:https://www.haiyun.me/archives/...
  • jiqz: make M=net/ipv4/ CONFIG_TCP_CONG_BBR=m modules编...
  • ruralhunter: 哦,文档里应该是对的,是.config
  • ruralhunter: cp /mnt/boot/config-4.18.7-aml-s9xxx .config这里应...
  • 海运: 你是编译不成功呢?还是编译后不能运行呢?还是运行后不能访问web界面呢?
  • 白墨: 可能不清楚就是编译安装后启动后访问不了web界面