<?php

namespace Ministra\Lib;

use Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\K131970f0a776522b1a53ba419cd5e32c;
use Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\U7b1423316998af8498523ab49b7053e6\Z0123335d0e9312494791d8030b626dff;
class XtreamCodes
{
    public static function getHash($mac_add, $ip, $channel_id, $max_seconds)
    {
        $encrypt = \Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\U7b1423316998af8498523ab49b7053e6\Z0123335d0e9312494791d8030b626dff::y08f4e0044959ef2ebbd1e3b0db7ed4ee($mac_add . '=' . $ip . '=' . $channel_id . '=' . (\time() + $max_seconds));
        $iv = \mcrypt_create_iv(\mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC), MCRYPT_DEV_URANDOM);
        $key = \pack('H*', \md5(\Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\K131970f0a776522b1a53ba419cd5e32c::get('xtream_key')));
        $mac = \hash_hmac('sha256', $encrypt, \substr(\bin2hex($key), -32));
        $passcrypt = \mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $encrypt . $mac, MCRYPT_MODE_CBC, $iv);
        $encoded = \urlencode(\base64_encode(\base64_encode($passcrypt) . '|' . \base64_encode($iv)));
        return $encoded;
    }
}
