source-class-Com.Tecnick.Pdf.Encrypt.Type.Seed

It appears that you are using AdBlocking software. The cost of running this website is covered by advertisements. If you like it please feel free to a small amount of money to secure the future of this website.
 1: <?php
 2: /**
 3:  * Seed.php
 4:  *
 5:  * @since       2011-05-23
 6:  * @category    Library
 7:  * @package     PdfEncrypt
 8:  * @author      Nicola Asuni <info@tecnick.com>
 9:  * @copyright   2011-2015 Nicola Asuni - Tecnick.com LTD
10:  * @license     http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
11:  * @link        https://github.com/tecnickcom/tc-lib-pdf-encrypt
12:  *
13:  * This file is part of tc-lib-pdf-encrypt software library.
14:  */
15: 
16: namespace Com\Tecnick\Pdf\Encrypt\Type;
17: 
18: use \Com\Tecnick\Pdf\Encrypt\Exception as EncException;
19: 
20: /**
21:  * Com\Tecnick\Pdf\Encrypt\Type\Seed
22:  *
23:  * generate random seed
24:  *
25:  * @since       2011-05-23
26:  * @category    Library
27:  * @package     PdfEncrypt
28:  * @author      Nicola Asuni <info@tecnick.com>
29:  * @copyright   2011-2015 Nicola Asuni - Tecnick.com LTD
30:  * @license     http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
31:  * @link        https://github.com/tecnickcom/tc-lib-pdf-encrypt
32:  */
33: class Seed
34: {
35:     /**
36:      * Encrypt the data
37:      *
38:      * @param string $data Random seed data
39:      * @param string $key  Random seed data
40:      * @param string $mode Default mode (openssl or raw)
41:      *
42:      * @return string Encrypted data string.
43:      */
44:     public function encrypt($data = '', $key = '', $mode = 'openssl')
45:     {
46:         $rnd = uniqid(rand().microtime(true), true);
47: 
48:         if (function_exists('posix_getpid')) {
49:             $rnd .= posix_getpid();
50:         }
51: 
52:         if (($mode == 'openssl')
53:             && function_exists('openssl_random_pseudo_bytes')
54:             && (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')) {
55:             // this is not used on windows systems because it is very slow for a know bug
56:             $rnd .= openssl_random_pseudo_bytes(512);
57:         } else {
58:             for ($idx = 0; $idx < 23; ++$idx) {
59:                 $rnd .= uniqid('', true);
60:             }
61:         }
62: 
63:         return $rnd.$data.__DIR__.__FILE__.$key.serialize($_SERVER).microtime(true);
64:     }
65: }
66: 
 

© 2004-2017 – Nicola Asuni - Tecnick.com - All rights reserved.
about - disclaimer - privacy