定制 hemiframe/php-aes 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hemiframe/php-aes

最新稳定版本:1.2.1

Composer 安装命令:

composer require hemiframe/php-aes

包简介

PHP class for encrypt and decrypt data with AES algorithm

README 文档

README

Supports

  • custom iv
  • auto generate iv
  • encode and decode data

Requirements

PHP >= 7.1

Installation

Enter in composer.json

{
    "require": {
        "hemiframe/php-aes": "~1.2"
    }
}

or run in console: php composer.phar require hemiframe/php-aes

Example

require_once('vendor/autoload.php');

$aes = new \HemiFrame\Lib\AES();
$aes->setKey("testkey");
$aes->setData("testdata");

$ivString = $aes->generateIv();
$aes->setIv($ivString);

$encryptedString = $aes->encrypt();
$aes->setData($encryptedString);
$decryptedString = $aes->decrypt();

echo "Available methods: " . implode(",", \HemiFrame\Lib\AES::getAvailableMethods()) . "<br/><br/>" . PHP_EOL;
echo "IV string: " . $ivString . "<br/>" . PHP_EOL;
echo "Encrypted string: " . $encryptedString . "<br/>" . PHP_EOL;
echo "Decrypted string: " . $decryptedString . "<br/>" . PHP_EOL;

Documentation

Methods

/**
 * Get encrypt/decrypt key
 * @return string|null
 */
public function getKey(): string

/**
 * Return encoded or decoded string
 * @return mixed
 */
public function getData();

/**
 * Get selected cipher method
 * @return string
 */
public function getMethod(): string

/**
 * Get available cipher methods
 * @return array
 */
public function getAvailableMethods(bool $aliases = false): array

/**
 * Gets selected iv string
 * @return string
 */
public function getIv(): string

/**
 * Generate a iv string for selected method
 * @return string|bool
 */
public function generateIv();

/**
 * Gets the cipher iv length
 * @return int|bool
 */
public function getIvLength();

/**
 * Set encrypt/decrypt key
 * @param string $key
 * @return $this
 * @throws \InvalidArgumentException
 */
public function setKey(string $key): self

/**
 * Set encrypt/decrypt method
 * @param string $method
 * @return $this
 * @throws \InvalidArgumentException
 */
public function setMethod(string $method);

/**
 * Set iv string
 * @param string $iv
 * @return $this
 * @throws \InvalidArgumentException
 */
public function setIv(string $iv): self

/**
 * Set encrypt/decrypt data
 * @param mixed $data
 * @return $this
 * @throws \InvalidArgumentException
 */
public function setData($data): self

/**
 * Returns the encrypted string on success or FALSE on failure.
 * @return string|bool
 * @throws \InvalidArgumentException
 */
public function encrypt();

/**
 * The decrypted string on success or FALSE on failure.
 * @return mixed
 * @throws \InvalidArgumentException
 */
public function decrypt();

统计信息

  • 总下载量: 29.19k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-12-25