decryptECB() public method

Decrypts blob data for standard images and videos.
public decryptECB ( data $data ) : data
$data data The data to decrypt.
return data The decrypted data.
コード例 #1
0
ファイル: snapchat.php プロジェクト: sadiqhirani/php-snapchat
 /**
  * Downloads a snap.
  *
  * @param string $id
  *   The snap ID.
  *
  * @return mixed
  *   The snap data or FALSE on failure.
  */
 public function getMedia($id)
 {
     // Make sure we're logged in and have a valid access token.
     if (!$this->auth_token || !$this->username) {
         return FALSE;
     }
     $timestamp = parent::timestamp();
     $result = parent::post('/blob', array('id' => $id, 'timestamp' => $timestamp, 'username' => $this->username), array($this->auth_token, $timestamp));
     if (parent::isMedia(substr($result, 0, 2))) {
         return $result;
     } else {
         $result = parent::decryptECB($result);
         if (parent::isMedia(substr($result, 0, 2))) {
             return $result;
         }
     }
     return FALSE;
 }
コード例 #2
0
 /**
  * Downloads a snap.
  *
  * @param string $id
  *   The snap ID.
  *
  * @return mixed
  *   The snap data or FALSE on failure.
  *     Snap data can returned as an Array of more than one file.
  * 	array(
  * 		overlay~zip-CE6F660A-4A9F-4BD6-8183-245C9C75B8A0    => overlay_file_data,
  *		media~zip-CE6F660A-4A9F-4BD6-8183-245C9C75B8A0	    => m4v_file_data
  * 	)
  */
 public function getMedia($id)
 {
     // Make sure we're logged in and have a valid access token.
     if (!$this->auth_token || !$this->username) {
         return FALSE;
     }
     $timestamp = parent::timestamp();
     $result = parent::post('/blob', array('id' => $id, 'timestamp' => $timestamp, 'username' => $this->username), array($this->auth_token, $timestamp));
     if (parent::isMedia(substr($result, 0, 2))) {
         return $result;
     } else {
         $result = parent::decryptECB($result);
         if (parent::isMedia(substr($result, 0, 2))) {
             return $result;
         }
         //When a snapchat video is sent with "text" or overlay
         //the overlay is a transparent PNG file Zipped together
         //with the M4V file.
         //First two bytes are "PK" x50x4B; thus the previous media check
         //will fail and would've returned a FALSE on an available media.
         if (parent::isCompressed(substr($result, 0, 2))) {
             //Uncompress
             $result = parent::unCompress($result);
             //Return Media and Overlay
             return $result;
         }
     }
     return FALSE;
 }