當前位置: 首頁>>代碼示例>>PHP>>正文


PHP TCPDF_STATIC::convertHexStringToString方法代碼示例

本文整理匯總了PHP中TCPDF_STATIC::convertHexStringToString方法的典型用法代碼示例。如果您正苦於以下問題:PHP TCPDF_STATIC::convertHexStringToString方法的具體用法?PHP TCPDF_STATIC::convertHexStringToString怎麽用?PHP TCPDF_STATIC::convertHexStringToString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在TCPDF_STATIC的用法示例。


在下文中一共展示了TCPDF_STATIC::convertHexStringToString方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: SetProtection


//.........這裏部分代碼省略.........
  * @param $user_pass (String) user password. Empty by default.
  * @param $owner_pass (String) owner password. If not specified, a random value is used.
  * @param $mode (int) encryption strength: 0 = RC4 40 bit; 1 = RC4 128 bit; 2 = AES 128 bit; 3 = AES 256 bit.
  * @param $pubkeys (String) array of recipients containing public-key certificates ('c') and permissions ('p'). For example: array(array('c' => 'file://../examples/data/cert/tcpdf.crt', 'p' => array('print')))
  * @public
  * @since 2.0.000 (2008-01-02)
  * @author Nicola Asuni
  */
 public function SetProtection($permissions = array('print', 'modify', 'copy', 'annot-forms', 'fill-forms', 'extract', 'assemble', 'print-high'), $user_pass = '', $owner_pass = null, $mode = 0, $pubkeys = null)
 {
     if ($this->pdfa_mode) {
         // encryption is not allowed in PDF/A mode
         return;
     }
     $this->encryptdata['protection'] = TCPDF_STATIC::getUserPermissionCode($permissions, $mode);
     if ($pubkeys !== null and is_array($pubkeys)) {
         // public-key mode
         $this->encryptdata['pubkeys'] = $pubkeys;
         if ($mode == 0) {
             // public-Key Security requires at least 128 bit
             $mode = 1;
         }
         if (!function_exists('openssl_pkcs7_encrypt')) {
             $this->Error('Public-Key Security requires openssl library.');
         }
         // Set Public-Key filter (availabe are: Entrust.PPKEF, Adobe.PPKLite, Adobe.PubSec)
         $this->encryptdata['pubkey'] = true;
         $this->encryptdata['Filter'] = 'Adobe.PubSec';
         $this->encryptdata['StmF'] = 'DefaultCryptFilter';
         $this->encryptdata['StrF'] = 'DefaultCryptFilter';
     } else {
         // standard mode (password mode)
         $this->encryptdata['pubkey'] = false;
         $this->encryptdata['Filter'] = 'Standard';
         $this->encryptdata['StmF'] = 'StdCF';
         $this->encryptdata['StrF'] = 'StdCF';
     }
     if ($mode > 1) {
         // AES
         if (!extension_loaded('mcrypt')) {
             $this->Error('AES encryption requires mcrypt library (http://www.php.net/manual/en/mcrypt.requirements.php).');
         }
         if (mcrypt_get_cipher_name(MCRYPT_RIJNDAEL_128) === false) {
             $this->Error('AES encryption requires MCRYPT_RIJNDAEL_128 cypher.');
         }
         if ($mode == 3 and !function_exists('hash')) {
             // the Hash extension requires no external libraries and is enabled by default as of PHP 5.1.2.
             $this->Error('AES 256 encryption requires HASH Message Digest Framework (http://www.php.net/manual/en/book.hash.php).');
         }
     }
     if ($owner_pass === null) {
         $owner_pass = md5(TCPDF_STATIC::getRandomSeed());
     }
     $this->encryptdata['user_password'] = $user_pass;
     $this->encryptdata['owner_password'] = $owner_pass;
     $this->encryptdata['mode'] = $mode;
     switch ($mode) {
         case 0:
             // RC4 40 bit
             $this->encryptdata['V'] = 1;
             $this->encryptdata['Length'] = 40;
             $this->encryptdata['CF']['CFM'] = 'V2';
             break;
         case 1:
             // RC4 128 bit
             $this->encryptdata['V'] = 2;
             $this->encryptdata['Length'] = 128;
             $this->encryptdata['CF']['CFM'] = 'V2';
             if ($this->encryptdata['pubkey']) {
                 $this->encryptdata['SubFilter'] = 'adbe.pkcs7.s4';
                 $this->encryptdata['Recipients'] = array();
             }
             break;
         case 2:
             // AES 128 bit
             $this->encryptdata['V'] = 4;
             $this->encryptdata['Length'] = 128;
             $this->encryptdata['CF']['CFM'] = 'AESV2';
             $this->encryptdata['CF']['Length'] = 128;
             if ($this->encryptdata['pubkey']) {
                 $this->encryptdata['SubFilter'] = 'adbe.pkcs7.s5';
                 $this->encryptdata['Recipients'] = array();
             }
             break;
         case 3:
             // AES 256 bit
             $this->encryptdata['V'] = 5;
             $this->encryptdata['Length'] = 256;
             $this->encryptdata['CF']['CFM'] = 'AESV3';
             $this->encryptdata['CF']['Length'] = 256;
             if ($this->encryptdata['pubkey']) {
                 $this->encryptdata['SubFilter'] = 'adbe.pkcs7.s5';
                 $this->encryptdata['Recipients'] = array();
             }
             break;
     }
     $this->encrypted = true;
     $this->encryptdata['fileid'] = TCPDF_STATIC::convertHexStringToString($this->file_id);
     $this->_generateencryptionkey();
 }
開發者ID:TheTypoMaster,項目名稱:myapps,代碼行數:101,代碼來源:tcpdf.php


注:本文中的TCPDF_STATIC::convertHexStringToString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。