Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Crypt / Symmetric / Padding / Pkcs7.php
blob9589aa5072ac6ee8c9250aeb5640bce19418331e
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Crypt\Symmetric\Padding;
12 /**
13 * PKCS#7 padding
15 class Pkcs7 implements PaddingInterface
18 /**
19 * Pad the string to the specified size
21 * @param string $string The string to pad
22 * @param int $blockSize The size to pad to
24 * @return string The padded string
26 public function pad($string, $blockSize = 32)
28 $pad = $blockSize - (strlen($string) % $blockSize);
29 return $string . str_repeat(chr($pad), $pad);
32 /**
33 * Strip the padding from the supplied string
35 * @param string $string The string to trim
37 * @return string The unpadded string
39 public function strip($string)
41 $end = substr($string, -1);
42 $last = ord($end);
43 $len = strlen($string) - $last;
44 if (substr($string, $len) == str_repeat($end, $last)) {
45 return substr($string, 0, $len);
47 return false;