Skip to content

Commit

Permalink
单元测试
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexchent committed Mar 27, 2019
1 parent 2e64577 commit b8b00a8
Show file tree
Hide file tree
Showing 9 changed files with 1,136 additions and 1 deletion.
45 changes: 45 additions & 0 deletions Helper/AES.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
/**
* AES加密、解密工具包
* Created by PhpStorm.
* User: tao.chen
* Date: 2017/12/11
* Time: 15:25
*/

namespace Helper;

class AES {

/**
* 加密方法
* @param string $input
* @param string $key
* @return string
*/
public static function aes_encrypt($input, $key)
{
//AES, 128 模式加密数据 ECB
$md5key = strtoupper(md5($key));
$key = hex2bin($md5key);
$encrypted = openssl_encrypt($input,'AES-128-ECB',$key);
return $encrypted;
}


/**
* 解密方法
* @param string $encrypted
* @param string $key
* @return string
*/
public static function aes_decrypt($encrypted, $key)
{
//AES, 128 模式加密数据 ECB
$md5key = strtoupper(md5($key));
$key = hex2bin($md5key);
$decrypted = openssl_decrypt($encrypted,'AES-128-ECB',$key);
return $decrypted;
}
}

Loading

0 comments on commit b8b00a8

Please sign in to comment.