phpseclib\Common\Functions\Strings::shift PHP Méthode

shift() static public méthode

Inspired by array_shift
static public shift ( string &$string, integer $index = 1 ) : string
$string string
$index integer
Résultat string
    static function shift(&$string, $index = 1)
    {
        $substr = substr($string, 0, $index);
        $string = substr($string, $index);
        return $substr;
    }

Usage Example

Exemple #1
0
 /**
  * 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 = '')
 {
     if (!is_string($key)) {
         return false;
     }
     $parts = explode(' ', $key, 3);
     $key = isset($parts[1]) ? Base64::decode($parts[1]) : Base64::decode($parts[0]);
     if ($key === false) {
         return false;
     }
     $comment = isset($parts[2]) ? $parts[2] : false;
     if (substr($key, 0, 11) != "ssh-rsa") {
         return false;
     }
     Strings::shift($key, 11);
     if (strlen($key) <= 4) {
         return false;
     }
     extract(unpack('Nlength', Strings::shift($key, 4)));
     if (strlen($key) <= $length) {
         return false;
     }
     $publicExponent = new BigInteger(Strings::shift($key, $length), -256);
     if (strlen($key) <= 4) {
         return false;
     }
     extract(unpack('Nlength', Strings::shift($key, 4)));
     if (strlen($key) != $length) {
         return false;
     }
     $modulus = new BigInteger(Strings::shift($key, $length), -256);
     return array('isPublicKey' => true, 'modulus' => $modulus, 'publicExponent' => $publicExponent, 'comment' => $comment);
 }
All Usage Examples Of phpseclib\Common\Functions\Strings::shift
Strings