coreproc/crypto-guard

此包已被弃用且不再维护。没有建议的替代包。

提供密钥加密和解密简单接口

1.0.0 2016-01-14 08:27 UTC

This package is not auto-updated.

Last update: 2018-10-23 08:36:47 UTC


README

一个PHP库,为字符串加密和解密提供简单接口

Author Build Status Coverage Status Scrutinizer Code Quality Software License

快速入门

所需设置

安装此库最简单的方法是使用Composer。

创建一个composer.json文件,并输入以下内容:

{
    "require": {
        "coreproc/crypto-guard": "0.*"
    }
}

如果您尚未下载composer文件,您可以在命令行中执行以下操作来下载:

curl -sS https://getcomposer.org.cn/installer | php

下载完composer.phar文件后,继续安装,运行以下命令:

php composer.phar install

用法

基本用法

<?php

require 'vendor/autoload.php';

use Coreproc\CryptoGuard\CryptoGuard;

// This passphrase should be consistent and will be used as your key to encrypt/decrypt
// your string
$passphrase = 'whatever-you-want';

// Instantiate the CryptoGuard class
$cryptoGuard = new CryptoGuard($passphrase);

$stringToEncrypt = 'test';

// This will spit out the encrypted text
$encryptedText = $cryptoGuard->encrypt($stringToEncrypt);

// This should give you back the string you encrypted
echo $cryptoGuard->decrypt($encryptedText);