承接 martinusso/opencrypt 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

martinusso/opencrypt

最新稳定版本:3.1.0

Composer 安装命令:

composer require martinusso/opencrypt

包简介

Two-way encryption (encrypt and decrypt) data using PHP with OpenSSL

README 文档

README

Build Status Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version Latest Unstable Version License composer.lock

Two-way encryption (encrypt and decrypt) data using PHP with OpenSSL

Installation

composer require martinusso/opencrypt

Tips

  • $secretKey should have been previously generated in a cryptographically safe way, like openssl_random_pseudo_bytes. OpenCrypt has a static method OpenCrypt::generateKey() for this.

Usage

$password = "OpenCrypt";

// Should have been previously generated in a cryptographically safe way
$secretKey = 'SECRET_KEY';

// You can pass the IV as argument or it is generated automatically
$openCrypt = new OpenCrypt($secretKey [, string $iv ]);

// get the IV
$iv = $openCrypt->iv();

// encrypt
$encryptedPassword = $openCrypt->encrypt($password);
// $encryptedPassword = 'GWw3bqL7FqjmRs0yyIR/8A=='

// decrypt
$decryptedPassword = $openCrypt->decrypt($encryptedPassword);
// $decryptedPassword = 'OpenCrypt'

generate IV

OpenCrypt offers a static method to generate a safe IV:

$iv = OpenCrypt::generateIV();

generate key

it is also possible to generate a safe secret key:

$secretKey = OpenCrypt::generateKey();

License

This software is open source, licensed under the The MIT License (MIT). See LICENSE for details.

统计信息

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

GitHub 信息

  • Stars: 8
  • Watchers: 1
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-10-24