fdevs/padding

FDevs Padding Component

0.1.0 2016-07-27 07:18 UTC

This package is auto-updated.

Last update: 2024-03-28 17:51:38 UTC


README

Build Status

Installation

Padding uses Composer, please checkout the composer website for more information.

The simple following command will install fdevs/padding into your project. It also add a new entry in your composer.json and update the composer.lock as well.

composer require fdevs/padding

Usage examples

basic usage

<?php
use FDevs\Padding\Pkcs7;
use FDevs\Padding\NoPadding;

$padding = new Pkcs7();

$data = '';//your data without padding
$blockSize = 32;//your block size default 32
$paddingData = $padding->pad($data,$blockSize);

echo $padding->unpad($paddingData, $blockSize); 

usage with mcrypt

<?php
use FDevs\Padding\Pkcs7;

$padding = new Pkcs7();

$data = '';//your data without padding
$key = '';//your secret keys
$blockSize = mcrypt_get_block_size('des', 'ecb');

echo mcrypt_encrypt(MCRYPT_DES, $key, $padding->pad($data,$blockSize), MCRYPT_MODE_ECB);

$str = '';//crypto data
$paddingData = $str = mcrypt_decrypt(MCRYPT_DES, $key, $str, MCRYPT_MODE_ECB);

echo $padding->unpad($paddingData, $blockSize); 

License

This library is under the MIT license. See the complete license in the library:

LICENSE

Created by 4devs - Check out our blog for more insight into this and other open-source projects we release.