load() static public method

Break a public or private key down into its constituent components
static public load ( string $key, string $password = '' ) : array
$key string
$password string optional
return array
コード例 #1
0
ファイル: PKCS8.php プロジェクト: phpseclib/phpseclib
 /**
  * Break a public or private key down into its constituent components
  *
  * @access public
  * @param string $key
  * @param string $password optional
  * @return array
  */
 static function load($key, $password = '')
 {
     $components = ['isPublicKey' => strpos($key, 'PUBLIC') !== false];
     $key = parent::load($key, $password);
     if ($key === false) {
         return false;
     }
     $type = isset($key['privateKey']) ? 'private' : 'public';
     if ($key[$type . 'KeyAlgorithm']['algorithm'] != '1.2.840.113549.1.1.1') {
         return false;
     }
     $result = $components + PKCS1::load($key[$type . 'Key']);
     if (isset($key['meta'])) {
         $result['meta'] = $key['meta'];
     }
     return $result;
 }