咪视界(咪咕视频TV版)playurl的request入参body出参算法

技术文档:数据加密和请求过程

本文档描述了一个用于数据加密和发送加密请求的PHP代码片段。

功能说明

该代码片段具有以下功能:

  • 对给定的数据进行加密
  • 使用加密后的数据作为参数发送GET请求

依赖项

该代码片段依赖以下软件包/服务:

  • PHP:用于编写和执行代码
  • OpenSSL:用于数据加密

使用方式

以下是使用该代码片段的步骤:

  1. 定义要加密的数据:
$data = '{"h265":"false","session":"e3008a98f8ac4916b84aa7d0056add88","timestamp":"1737644942765","contId":"946389650","chip":"kirin9000","rateType":"4","os":"7.1.2","startPlay":"true","ott4k":"false","nt":"4","vivid":"0","drm":"false","ua":"NOP-AN00","flvEnable":"false"}';

  1. 定义加密密钥:
$key = "RQ0k7QDEEA4xe1fV";

  1. 调用encrypt函数加密数据:
$encrypted = encrypt($data, $key);

  1. 创建并配置cURL对象:
$curl = curl_init();
curl_setopt_array($curl, [ /* 配置选项 */ ]);

  1. 设置请求URL,包括加密后的数据作为请求参数:
curl_setopt($curl, CURLOPT_URL, 'https://play.a208.ottcn.com/playurl/videox/play/playurl?request='.$encrypted);

  1. 发送GET请求并获取响应:
$response = curl_exec($curl);

  1. 处理响应数据:
if ($err) {
    echo 'cURL Error #:' . $err;
} else {
    echo $response;
}

  1. 请求接口响应数据:
{"code":"200","rid":"SUCCESS","playCode":"100000","respId":"ac580bfb8bd3457166b3093aadb3e276_vsCOrz2Tqz8xN7Oxlb5qNA==","info":null,"message":"SUCCESS","httpmessage":null,"timeStamp":1737701252180,"body":"3ff44e382660b92209eb1abaaa470a8ff17c14efc84a63533a231da35a3e63aa63049075d12c451ecfa523f35bb1c7543ae081ec2b75f568bfbacab389d539c713692a0aee456b60a0d1c81a90ed255128fd13ccf27dd6233e47c3a30b3ea0e0271066752b5ab16cf9adb728e1231681af60f296591ea51ab01f18bedf2567d60b9c95e4980f21b8ffe9adb974c98866c4072e031b3875f6178f49fb045a1315c34303ca40c5b74889a08c381f677562235518a16fe9c6224652ff048c2815b9fb00a93a9f558df377f2bc269d578a5b5328ca9bb6b94e6217780f7452e109d613c7e4b17797918bd6b088cc56f285a77329964db697ca8f3d9ce72b5b693a05ce69c4353749812177d9663837a494a487e4be3d880ad9d9a37c9f71bee3a3b9842da4edaf48a9805abf14a130abebffcf769b4a0eb78e975130fce91f1e96e0e5ed44bca16d85252bc5f9bd186179886c0b5f7a648ef54db8194d407d1d5f34cf11b2f7f5a4d30b2d8f05628f62da2075451f3bc824e8dc599aa3d5f1e2e091665699ebf382cb13d5e7794d19c27f897b1941515e5859ab45f106fa081437d7e52fc7d121b911372827f88f9d61fa8cfd2b8bd470620a2d6e8bdeba1f2461319580e0fcd53acbf1bb83b96027f5f2e679a2aba06033c2815cf50c994bf7dbfb37c2d98d88934e1ece5fa5a3358045850894db981f5725aab856caf916bd348f0dd95f537f9aa9638c5a94305dc5fc97b10d2fd0b82c7c2a362095aa71ce69ef44fef4af1763a19b905649e0fb7dfed6d8951fe02b9c818422d972ebb406c443d905346c79f25c0af2a4c8accc05ea48d74e1865f29cedaad984ebaa9f934df6db2028452b274e90cb99f01c188a96ec0c567131b288f8466e2271dcf38a699aa1f751638e445b40b922ab73ec1c7fea1dafe6fce9073bacffee113124937cc83a515efdbf1b510d0969ce866eaa7cd9c4e861b9ee22a353a5493c7f964e9dc9993bf8e4b2542e19e0e11df36465324ec0d7022c5ec51f3c6be831072067a4d62f6b05c203ac3c1bb3e52d29e1a348e31a884ce341d7f340776c5706d1144d3d460836379fa0d64c4b3873e5f20e0c8c1670f2a9db0c9409610e26f378ed6109e295b7c0ac998372fa8bdeb7003c2c58513a0b2d9d0e51d2ab360267c909f165e1b98cb30f47465a9dc15f79a585abf85418b384c99fd3e4a08182dae379d2aeb7c622c5fc4719cc859d68f4be4335571090537feba0a5335e0655c841583b259e5fdf91eaed55f958e23347aad1bafa20e2787a0e31dd21fbb41d823d352d7d92f04becc90c0dff6d068aa2903a9a03e78c6dcd2b2f32362fba60b535cf2dae2efcebb0c25408297094d2cbc796fcf94af19facd75c64aaa1412e730b29caa6e4f3d824abe28df56bd7e4feb8fa4f3debb2725d1badf2104b185d045c7d458ffa2e779892e27bf05e2ed4c518bcd177b7fe3eb829fceb5579705999eb60b71362f2473c91a3a3c88f446160cffbd06e7d89f87bb9f977e55611e5c1704099b8c671b2d065ec7b5ab5c0bf4f1a2d75dd3155e5ddd90bcfb4e8dcfb6834830d28886a0e6c329d7f493e73fa3992942d9a49474180a2ef8347fcf5239e77bb9404b13c8f6555b03a15705e342d951fd62fff7abf464b30ebfbf4116840074f4c4953768122c065676b375efbc4dd7eefde580ce76e420d8369baf5f8f84948d230f83fe5d6c27753150b24b907fa74ba127b2ab252a00a70bad0d81e69a88488b747754ed63d393d6889899e6a8c6f424ba9901ce7e28c076c2e0e14044d83653e56f11dab8514474741f6dbbcf5b65acef2d0b9ddd2d30164c8589522b9d6498a55efd36f99a5e90f88349852fb85a5a5b75ee33e284a66de7651630d1530bd569805c246a7de8c4f0b1ef363b4262be000842d6b294ddb6b83ffc9b5853b26c9b35ee5d760c9e9176665a7cad02956216aceaeb75219dc28b8dc753c0226c0f18110a62cc288f6fab887e1e8d8fad1b0f783e286f8d046384955848a5b8d14c943e2aeb54ea7a2bea592b12e2e0c05372efcebb0c25408297094d2cbc796fcf94af19facd75c64aaa1412e730b29caa661f5442ee4f3904fe3123b3a9f4aec1ed062d7bd29fdc3f1b65967a48f3246ed3841c29597a66e92e9ee3f0ace430e63e6a717b1a0a9538f7bcf5447e7df8691de0b9462a1ca4d47b93f297e35344591f5d588b17f8efb3dced6a29799bb44043a504e93af6c49610bcadb69fe158ff92a88ebad90cdf53a08f6698d134529ba687622ed1052423786db7f59a07de589433028df8ed7d77bcf49d91bd7585cdc9dc2813c134037c78596843136008490060144b55334129513b78a810ec5b875ad4850449a3b852576b4b1c6fa6660d0402acf513e623616ac2117d8851651887e8a5dec78895c54dc162a3f9eb74649692628e4f71afa9e6a39799ba6c8ee677ddf379dea890d6c43f3d8fd3fe176b5376149727cf6e8e0417a7abb1bf5cc6893aaec70bdcff643530c548452696df2669fc9823c4b599901929cf5974e29204d4af5883d510a81a6e283a8871bce680efecfc7a9377b037b6a9018fe758b91ce2837a3e70939969984bfbccf0af545b9f08225a9ad84726d8555249c4b021fa32109c3375fc7bb3c7c79512ffc095704dff3b44eb54dc19b3ca27350b98a85368f8ca12d4cbaab4ddafb589765d899dcf975e460602a3be2c4f5b6fdb3e4bfc2d664ab63d47c7fa32205d94fa306dbccbbc7a9d2a8740586b5618672d321858ea9b4844c14615abf1c14af68f7267c03f897e8d0049b977a5193542740623387cda5b2b8a0abd78fcff76a8a18a5b68dd1403b0590ad764b62b63d632033e423a6fc9ed83f4b03b87dd7317796ad4528202cdf970436cc30bd4eddeca0bc22058d85b189644b4b518fc6647bbea131ba3e95a2a7bb71a3b6c9a2fbbb5458e734c2038b2bc90ce731760d0a2f14f04dcd3db389be14c814e369be2ea7ff3efcd39227477b405f24e9f4a56f824967c57790f0a94dd4be7a24b9c0e6f03f6cab4df908628e6498c28902f533a45cb28f49566adbff245ab0541c9a1d4af302cdea003cb17dffe07b4bd1534673462bd0502887da0acc8d50e0ac7068250a73dcb0e6eb79d57e3b58796e1a2f82bc6e761659c4d0a2e0fb668537029238399a60c5f8921c342aa5133c6b60f2ad96f86d2502abb4cb09bb55d4cec9839bb57981f97e3737303409374799d800c4028921d9bdcf437f36559d969ec68b2460a6b4ebd857a5051796425c55077445d41f2b1cd3c8ede7221603f6e80109e4de7fa21333490793242ced5c96d552a16dd00ea4636cedf8a71728d38ed549af136288b84d6c55e4aad2947ed782d961add30b9e9fb09b8652cf88a90c9f34ed2b965b20652b3ae157e32ecb082c0e01850f5b977700aa06f1c305a35b074e49dd7500824f85bbd481ca5f63619e13127db5d743e2aeb54ea7a2bea592b12e2e0c05378469153ac97fe3d96816be00fb7bf25821e5cb8adcaa0f994e834ad7b5d6a23ec2c5064aa94093a4b20315c81ed31270edfbdef80d689249fda7cbcb40304f9ff9d141dd75ea0c2d9b46d85ac9c5228ce60c5a903143360654118cf0a01bc399fa7bfd00e100c7340308fe97caeb2c35fc941d29a5056529960d6dc6e876cf258ee11ef3f3f6e8f7701808a873270d5232a83e81500f5ccfe376bfed1e57c2a7db29421eb09756c631b8ece740f4da9fd724c1d7c0537590b6c8262d6e17d0c17d4f8f4bca5b90d84ce4c787ea6e304ffde1aad95bdb3c0bee3a9e93e33448aa83cbffbd330a0d774e83f49d096dd0fadfbd413e6f415c5ad567cb605357479950f2912960dd0384d54a64783465e2a48b33693c3c8493c15705ee114d40c7a7b30c0c4947ac2bfc6f0e46f97eb1a54a60de699ed206eee08bfea9fe98a34043f0a831967f5527fd4ba45dad9815b4c6f2d00560afb365ab0bcca44408eaa63d149db61a7af6c6dc7d042b6e789808c87e21ab3eec3f56d29f309e63ea7dd46aedcf1d12451d81df38a54e0048843f775a7d3a4d51105071d64172d72db5558abcf97349e9d50774aff436be38dcc306d086bba154e2cff5a31e6f06cc138f8dd9b4bd02204522e67dd315e95243e88344c0d6d3180ab20304ae6c1852270f14ac0f53fd73fa3d5c36d2e3361acd687bcf95d06d750514fffa4886b8600b08c6125c7b5c0d60274cb9f73239a70f67ec151d8d7da84e09cc1a53ac93fa79c7b673b5b9838f19b9cf5a9a658ed16ded066d029c9e4c87d21bcc2f68de266d210bd8730486e6aca66d109e32f988252f067d8bb1d6cc58fe861e5988b5d9eae99d985d64a0c57c178459dca5d4b965956e2a58fd3bb4a45602c8013c879c74680d63e8acfc96030b8e506360c562ee5ebbc3762e84fb85720d10198ca38d2e175afcf17749603e2cc4f069850e85ab63ef18abb1256a0452bf45cac284bf707dad063050adb31eafbc8cb67f776a85ccf90cb226a38e2f4254fbcf9fb61522af93fe903999e3079f7a7f0d2ff9df05dd295f470fb28599b9919b30cb247b68dc6b3b5ed28ef67cec602328003fe2a2dd52772a8f2a1e0f19c7f203d6c69746f96447bbb976b4a65f96e582db3822d16498914bcbeba49c1d9256d1d22b8ae4f25afbe1cfbb7e4e79ef4e57290c72461b2cca118cfa42b0d90db49f0eacc3afd4f020ef480a93a05a189affaea96a11455e03063c38a18f5e506cf790d96a0d998744fef3dfabf4a9ebdaa681cf22f59eef098842af87a8263faf3009cbcfe059c3be4c883cf3ef7c08e21176200a45a5b98b7806ced44200f41090045c6067628fe7f0325ff6aff579c420b451aeb51e37c13955240fedcce88d11eacbef0e4afefa4dc88fc94c8a3fcacf9024ced19f3b31b126599998736c5eb8e18c4b825fd97541e1228584cb07b5258c136eccbf9c5b7392429b8c96db9fe415b3968e26663b9f4ec2ada3e3811effa1cf526a934ea30f1072b7e230b8e7220a86b19b96ffacbaf64bd73d59dfd0f6a6693906db62c944dac644ca38a335e9c0dd01351773d006bf3241f3ac1c5b805e46f0634104df675b42c58cd64c1cd2ca234aa2ca5132a5420d6b1f3f43a7f662933a285be2e6a128803abd211e738407b4970e2e545238d6bc6a359dc732066637e7542b550ece1d883f1a470cd458aee15238d3a2f2e3d860c400bb5b68ece2d67187eca37d84e98bcdbe3c23e794c0dfdaf0fa5a118151990910fbb070d7e66cd050c7efb4b88bf4d9d0bef3c84eab32a8f7c039c152cebce2b8b37d18f3a076bb803da461f5442ee4f3904fe3123b3a9f4aec1ed062d7bd29fdc3f1b65967a48f3246ed8119e62bdaf9c5005ecda652896bc4a674823fc8462ea517f855375911e8e53299a29864fa54ed1084d52b6e7cc8af4dbb4615f4adca9a28558b2bcdee597b3e545030886598a37a9ea521faff837b1ba52e5da02e76c04cc6c8e7d735e63cc6e004c51b907cedfd157c6d73feb53adfad6a5ab78d545e61dd6a7989ac6f5a7e824c686d8fa3160230a3b0497d7494337d575c659c8d5edd92c4be6033147e5ccf594d362c065f47eb7d4f561ba33e44ff8b9cc28912194aeaabe195d07669da322a946820eac4e7f0b875e39cd734f257cba05bac5e07b868833bbb779cd2e0e58d4f606b32a55f3faf3a98029f6b667f4bdef71f2edc6c7d9ac20571c56db5613f6fba13365f119a652d425e5b88865055a85f4c513afc4d6713aae619a2c8896b8e5de5954e04dd19423b1f3bc7db0c2013b17a17b81f4d6adbff4403b0e6c8947019f8794cfda12345bda4e923d4c264b3961e116ddbf96280ad3dc75e1067e25496b35c64b91403877e07527f1d344e0ab89ee5a027f254da3da80146d4fbc4039aecb94b62311e1b013e323099ae883895667c43fd1c7b8555411e17ce78deb442a20349d94765cdbdbbcae8891ea3a18713e89307f4c4834b1304181a63de39f9d7bd5fcf0fad9799a27f529140ee6d3e2c38ba0d4c0040d83d1add4deb2272c1250a244c6170c8d1a6b8a2d8cccab4ada9c2b85da58579410cd6cd186f74b3330330d4dc58ef530c153dcbba517696dbae01332f0e56f67bc14dd81341efa86ef7f24406ccdacf2c7f3e604d79e09b14ea8328b7eb59f656d62651bc2b80c769f9c3c7247968c87f9e870f22c755b1151629f09d6a2579926a80e629994660bad365ec7b34f8138d389d13b936e9116f502afd3a6d0e6777350689229bb4210141dd5e012343cba1d23891351a9be9ad17e286b1fe7f455e7190f68968959e229a060d139b61045197f02f02e519d37f8906c5578c5e7ffd56d18e7b10df1b10dfbef4f2fa46726dce3b49ab911e9ccbf3e188793f741067af4174a21a3de28f9d5a1153feabf869b48610cff8d9f3e2994988864ad7eb1cad0aaf213183627a975849188dddf326aace9fb463836e91da9dd336844f504c2bbd90f9285461113603ca98be304c6553debc50893257d7244bcf2fa0d5100b5f919c59911806600a0adf709d09dfe4bbbf9be0"}

取返回结果body的值进行解密

$decrypted = decrypt($data, $key);

数据加密方法

该代码使用AES-128-ECB算法对数据进行加密。加密函数的实现如下:

function encrypt($data, $key): string
{
    $blockSize = 16;
    $pad = $blockSize - (strlen($data) % $blockSize);
    $data .= str_repeat(chr($pad), $pad);
    $encrypted = openssl_encrypt($data, "aes-128-ecb", $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING);
    return bin2hex($encrypted);
}

数据解密方法

该代码使用AES-128-ECB算法对数据进行解密。解密函数的实现如下:

function decrypt($data, $key): string
{
    $encrypted = hex2bin($data);
    $decrypted = openssl_decrypt($encrypted, "aes-128-ecb", $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING);
    
    // Remove the padding
    $pad = ord($decrypted[strlen($decrypted) - 1]);
    $decrypted = substr($decrypted, 0, -$pad);
    
    return $decrypted;
}

以上函数接受两个参数:要加密的数据和加密密钥。它首先根据加密算法的块大小计算数据的补位大小,并将补位字符添加到数据末尾。然后使用OpenSSL函数进行加密,并将加密结果转换为十六进制字符串。 

请求配置

在cURL对象中,以下请求配置选项被设置:

  • CURLOPT_URL: 请求的URL,包括加密后的数据作为请求参数
  • CURLOPT_RETURNTRANSFER: 设置为true,以便将响应作为字符串返回
  • CURLOPT_ENCODING: 设置编码方式为空,以便支持所有类型的编码
  • CURLOPT_SSL_VERIFYPEERCURLOPT_SSL_VERIFYHOST: 设置为false,以便忽略SSL证书验证
  • CURLOPT_MAXREDIRS: 设置重定向最大次数
  • CURLOPT_TIMEOUT: 设置请求超时时间
  • CURLOPT_HTTP_VERSION: 设置HTTP协议版本为1.1
  • CURLOPT_CUSTOMREQUEST: 设置请求方法为GET
  • CURLOPT_HTTPHEADER: 设置请求头信息

注意事项

请注意以下几点:

  • 该代码片段仅适用于使用AES-128-ECB算法进行加密的情况。如果需要使用其他加密算法,请相应地更改代码。
  • 请确保在服务器上安装了OpenSSL扩展以支持数据加密。
  • 请注意在实际使用中可能涉及到的安全问题和最佳实践,如SSL证书验证、请求参数验证等。

参考资料

This document This document contains some information about MUM and SOMA installation, and it is organized as follows: Needed software; Base software installation; Ant, MUM and SOMA installation. Directory tree. Needed software Before starting the installation you must download the following software: Java Software Development Kit (JSDK) Standard Edition 1.3.0 or following (I'm actually using version 1.4.1). You can download the JSDK from JSDK SE on the Sun site. Java Media Framework (JMF) 2.1.1e, you can download the Cross Platform version or the Performance Pack version for your operating system (there are available versions for Windows, Linux and Solaris OSs). We recommend to use the Performance Pack version when possible as it is more performing. You can download the JMF from JMF home page on Sun site. Base software installation For the installation of the base code follow these steps: Install the JSDK, information for the installation process can be found in the JSK SE home; Install the JMF, information for the installation process can be found in the JMF home; Let's call JMF2.1.1 the installation directory of the JMF and JSDK the installation directory of the JSDK. Copy there files: ./JMF2.1.1/lib/jmf.jar ./JMF2.1.1/lib/sound.jar to the directory: ./JSDK/jre/lib/ext. Note: these jar files contain the JMF classes used by the virtual machine at the runtime. Ant, MUM and SOMA installation Unzip the zip file you downloaded (this readme is part of that zip) to your work directory. A version of Ant, the build tool used to build and distribute the MUM project, can be downloaded here. Install Ant on your desktop. Change the setupMUM batch file so that the absolute paths to the Ant home and JSDK are correct. Now you have finished the installation and you can launch the system! First launch exec the setupMUM batch file. To run the middleware from the console digit: ant run. To compile the middleware from the console digit: ant run. To delete the MUM .class files digit: ant clean. clean. To docuement the MUM middleware digit: ant javadocs. Notes To use the prototype there must be at least one video presentation, and register it to the middleware. Therefore we included a presentation in this distribution that is starWarsH263Medium.mov. To register the presentation: Run the middleware: "ant run" ; Open the window of the SOMA place where you want to register the presentation; Launch from that place the RegisterPresentationAgent and fill in the fields as required. Directory tree When you unzip the distribution this is the directory tree: MUM: contains this readme.htm and the batch files setupMUM.bat and setupMUM.sh. lib: contains some useful jars .jar used to compile the project Ant. src contains SOMA and MUM. agents: contains the source code of the Mobile Agents (the mobile part of the MUM middleware). MUM: this is the root directory of the MUM project. You can find here all the source code of MUM middleware. SOMA: contains the SOMA middleware source code. filmati: contains the presentation starWarsH263Medium.mov. docs: contains the project documentation. The most recent API documentation is also available at this link: docs. META-INF: contains the .manifest file to automacally produce a jar file of the whole project. logsProps: contains the rules for logging with log4j. repositories: contains the DB used to store some info used for the prototype execution.
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值