<?php

namespace Ministra\Lib;

use Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\k8281faec2a4a41f470b00112682ddabf;
class XtreamCodes
{
    public static function getHash($mac_add, $ip, $channel_id, $max_seconds)
    {
        $encrypt = \Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\t17d3317196ac950e8b2dfe26f26e5a0c($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\w13ec15f0067ea75861e61e27c990e4ba\k8281faec2a4a41f470b00112682ddabf::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;
    }
}
