internetpixels/sodium-encryption
最新稳定版本:1.0.0
Composer 安装命令:
composer require internetpixels/sodium-encryption
包简介
Encrypt and decrypt data with this easy to use PHP encryption library
README 文档
README
Protect your data and secure every field in your entities with this tiny encryption library!
This is a open-source library. Please consider a link to this repository when you're actively using it.
Install with composer
This small encryption/decryption library can be required by using composer. Please use the following command:
composer require internetpixels/sodium-encryption
Setup the TokenManager
You have to set the secret and public tokens once. Those keys are not allowed to change overtime!
<?php // Update the keys (create a new unique keypair)! \InternetPixels\SodiumEncryption\EncryptionManager::setKeys( '1d17336ba7b2cec7dc8ec788e78ebf835d9f85cfc414275e92fd8e3ae5d6d2b6', 'b88fc95850eec82492e9f0616cfeb69b9205735e34f5ce5e83d681eb38147d57' );
Encrypt a field
We advise you to create a unique nonce per entity (use the EncryptionManager::generateNonce() method). You'll have to save the nonce with your data too, because it will be used when you want to decrypt the data again.
<?php $string = 'This is my default text string with 88 numbers!'; $nonce = EncryptionManager::generateNonce(); $encrypted = EncryptionManager::encrypt($string, $nonce);
Decrypt a field
In order to decrypt a field, you'll need the encrypted string and the nonce.
<?php $string = EncryptionManager::decrypt($encrypted, $nonce);
统计信息
- 总下载量: 3.18k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2018-06-15