本文整理汇总了PHP中WindowsAzure\Common\Internal\Utilities::base256ToDec方法的典型用法代码示例。如果您正苦于以下问题:PHP Utilities::base256ToDec方法的具体用法?PHP Utilities::base256ToDec怎么用?PHP Utilities::base256ToDec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WindowsAzure\Common\Internal\Utilities
的用法示例。
在下文中一共展示了Utilities::base256ToDec方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIngestEncryptedAssetAndDecryptAtAzure
public function testIngestEncryptedAssetAndDecryptAtAzure()
{
// Setup
$content = TestResources::MEDIA_SERVICES_DUMMY_FILE_CONTENT;
$aesKey = Utilities::generateCryptoKey(32);
$protectionKeyId = $this->restProxy->getProtectionKeyId(ProtectionKeyTypes::X509_CERTIFICATE_THUMBPRINT);
$protectionKey = $this->restProxy->getProtectionKey($protectionKeyId);
$contentKey = new ContentKey();
$contentKey->setContentKey($aesKey, $protectionKey);
$contentKey->setProtectionKeyId($protectionKeyId);
$contentKey->setProtectionKeyType(ProtectionKeyTypes::X509_CERTIFICATE_THUMBPRINT);
$contentKey->setContentKeyType(ContentKeyTypes::STORAGE_ENCRYPTION);
$contentKey = $this->createContentKey($contentKey);
$asset = new Asset(Asset::OPTIONS_STORAGE_ENCRYPTED);
$asset->setName(TestResources::MEDIA_SERVICES_ASSET_NAME . $this->createSuffix());
$asset = $this->createAsset($asset);
$this->restProxy->linkContentKeyToAsset($asset, $contentKey);
$initializationVector = Utilities::generateCryptoKey(8);
$encrypted = Utilities::ctrCrypt($content, $aesKey, str_pad($initializationVector, 16, chr(0)));
// Test
$access = new AccessPolicy(TestResources::MEDIA_SERVICES_ACCESS_POLICY_NAME . $this->createSuffix());
$access->setDurationInMinutes(30);
$access->setPermissions(AccessPolicy::PERMISSIONS_WRITE);
$access = $this->createAccessPolicy($access);
$locator = new Locator($asset, $access, Locator::TYPE_SAS);
$locator->setName(TestResources::MEDIA_SERVICES_LOCATOR_NAME . $this->createSuffix());
$locator->setStartTime(new \DateTime('now -5 minutes'));
$locator = $this->createLocator($locator);
$fileName = TestResources::MEDIA_SERVICES_DUMMY_FILE_NAME;
$this->restProxy->uploadAssetFile($locator, $fileName, $encrypted);
$this->restProxy->createFileInfos($asset);
$files = $this->restProxy->getAssetAssetFileList($asset);
$files[0]->setIsEncrypted(true);
$files[0]->setEncryptionKeyId($contentKey->getId());
$files[0]->setEncryptionScheme(EncryptionSchemes::STORAGE_ENCRYPTION);
$files[0]->setEncryptionVersion(Resources::MEDIA_SERVICES_ENCRYPTION_VERSION);
$files[0]->setInitializationVector(Utilities::base256ToDec($initializationVector));
$this->restProxy->updateAssetFile($files[0]);
$decodeProcessor = $this->restProxy->getLatestMediaProcessor(TestResources::MEDIA_SERVICES_DECODE_PROCESSOR_NAME);
$task = new Task(TestResources::getMediaServicesTask($this->getOutputAssetName()), $decodeProcessor->getId(), TaskOptions::NONE);
$job = new Job();
$job->setName(TestResources::MEDIA_SERVICES_JOB_NAME . $this->createSuffix());
$job = $this->createJob($job, array($asset), array($task));
$this->waitJobStatus($job, array(Job::STATE_FINISHED, Job::STATE_ERROR));
$this->assertEquals($this->restProxy->getJobStatus($job), Job::STATE_FINISHED);
$outputAssets = $this->restProxy->getJobOutputMediaAssets($job);
$this->assertCount(1, $outputAssets);
$accessPolicy = new AccessPolicy(TestResources::MEDIA_SERVICES_ACCESS_POLICY_NAME . $this->createSuffix());
$accessPolicy->setDurationInMinutes(300);
$accessPolicy->setPermissions(AccessPolicy::PERMISSIONS_READ);
$accessPolicy = $this->createAccessPolicy($accessPolicy);
$locator = new Locator($outputAssets[0], $accessPolicy, Locator::TYPE_SAS);
$locator->setName(TestResources::MEDIA_SERVICES_LOCATOR_NAME . $this->createSuffix());
$locator->setStartTime(new \DateTime('now -5 minutes'));
$locator = $this->createLocator($locator);
// without sleep() Locator hasn't enough time to create URL, so that's why we have to use at least sleep(30)
sleep(40);
$method = Resources::HTTP_GET;
$url = new Url($locator->getBaseUri() . '/' . TestResources::MEDIA_SERVICES_DUMMY_FILE_NAME . $locator->getContentAccessComponent());
$filters = array();
$statusCode = Resources::STATUS_OK;
$httpClient = new HttpClient();
$httpClient->setMethod($method);
$httpClient->setExpectedStatusCode($statusCode);
$actual = $httpClient->send($filters, $url);
$this->assertEquals($content, $actual);
}
示例2: testBase256ToDecBig
/**
* @covers WindowsAzure\Common\Internal\Utilities::base256ToDec
*/
public function testBase256ToDecBig()
{
// Setup
$data = pack('C*', 81, 35, 29, 39, 236, 104, 105, 144);
//51 23 1D 27 EC 68 69 90
$expected = '5846548798564231568';
// Test
$actual = Utilities::base256ToDec($data);
// Assert
$this->assertEquals($expected, $actual);
}