当前位置: 首页>>代码示例>>PHP>>正文


PHP Utilities::generateCryptoKey方法代码示例

本文整理汇总了PHP中WindowsAzure\Common\Internal\Utilities::generateCryptoKey方法的典型用法代码示例。如果您正苦于以下问题:PHP Utilities::generateCryptoKey方法的具体用法?PHP Utilities::generateCryptoKey怎么用?PHP Utilities::generateCryptoKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WindowsAzure\Common\Internal\Utilities的用法示例。


在下文中一共展示了Utilities::generateCryptoKey方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testRemoveContentKeyFromAsset

 /**
  * @covers WindowsAzure\MediaServices\MediaServicesRestProxy::removeContentKeyFromAsset
  */
 public function testRemoveContentKeyFromAsset()
 {
     // Setup
     $aesKey = Utilities::generateCryptoKey(32);
     $protectionKeyId = $this->restProxy->getProtectionKeyId(ContentKeyTypes::COMMON_ENCRYPTION);
     $protectionKey = $this->restProxy->getProtectionKey($protectionKeyId);
     $contentKey = new ContentKey();
     $contentKey->setContentKey($aesKey, $protectionKey);
     $contentKey->setProtectionKeyId($protectionKeyId);
     $contentKey->setProtectionKeyType(ProtectionKeyTypes::X509_CERTIFICATE_THUMBPRINT);
     $contentKey->setContentKeyType(ContentKeyTypes::COMMON_ENCRYPTION);
     $contentKey = $this->createContentKey($contentKey);
     $asset = new Asset(Asset::OPTIONS_COMMON_ENCRYPTION_PROTECTED);
     $asset->setName(TestResources::MEDIA_SERVICES_ASSET_NAME . $this->createSuffix());
     $asset = $this->createAsset($asset);
     $this->restProxy->linkContentKeyToAsset($asset, $contentKey);
     // Test
     $this->restProxy->removeContentKeyFromAsset($asset, $contentKey);
     // Assert
     $contentKeyFromAsset = $this->restProxy->getAssetContentKeys($asset);
     $this->assertEmpty($contentKeyFromAsset);
 }
开发者ID:southworkscom,项目名称:azure-sdk-for-php,代码行数:25,代码来源:MediaServicesRestProxyTest.php

示例2: testBulkIngestEncryptedAsset

 public function testBulkIngestEncryptedAsset()
 {
     // Setup
     $asset = new Asset(Asset::OPTIONS_STORAGE_ENCRYPTED);
     $asset->setName(TestResources::MEDIA_SERVICES_ASSET_NAME . $this->createSuffix());
     $asset = $this->createAsset($asset);
     $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);
     $this->restProxy->linkContentKeyToAsset($asset, $contentKey);
     $fileName = TestResources::MEDIA_SERVICES_DUMMY_FILE_NAME;
     $otherFileName = TestResources::MEDIA_SERVICES_DUMMY_FILE_NAME_1;
     $manifest = new IngestManifest();
     $manifest->setName('IngestManifest' . $this->createSuffix());
     $manifest = $this->createIngestManifest($manifest);
     $manifestAsset = new IngestManifestAsset($manifest->getId());
     $manifestAsset = $this->createIngestManifestAsset($manifestAsset, $asset);
     $manifestFile1 = new IngestManifestFile($fileName, $manifest->getId(), $manifestAsset->getId());
     $manifestFile2 = new IngestManifestFile($otherFileName, $manifest->getId(), $manifestAsset->getId());
     $initializationVector1 = base64_encode(Utilities::generateCryptoKey(8));
     $initializationVector2 = base64_encode(Utilities::generateCryptoKey(8));
     $manifestFile1->setIsEncrypted(true);
     $manifestFile1->setEncryptionKeyId($contentKey->getId());
     $manifestFile1->setEncryptionScheme(EncryptionSchemes::STORAGE_ENCRYPTION);
     $manifestFile1->setEncryptionVersion(Resources::MEDIA_SERVICES_ENCRYPTION_VERSION);
     $manifestFile1->setInitializationVector($initializationVector1);
     $manifestFile2->setIsEncrypted(true);
     $manifestFile2->setEncryptionKeyId($contentKey->getId());
     $manifestFile2->setEncryptionScheme(EncryptionSchemes::STORAGE_ENCRYPTION);
     $manifestFile2->setEncryptionVersion(Resources::MEDIA_SERVICES_ENCRYPTION_VERSION);
     $manifestFile2->setInitializationVector($initializationVector2);
     $manifestFile1 = $this->createIngestManifestFile($manifestFile1);
     $manifestFile2 = $this->createIngestManifestFile($manifestFile2);
     $initialStat = $this->restProxy->getIngestManifest($manifest);
     $blobUrl = $manifest->getBlobStorageUriForUpload();
     $blobUrlParts = explode('/', $blobUrl);
     $blob = array_pop($blobUrlParts);
     $blobRestProxy = $this->builder->createBlobService($this->connectionString);
     $blobRestProxy->createBlockBlob($blob, $fileName, TestResources::MEDIA_SERVICES_DUMMY_FILE_CONTENT);
     $this->waitIngestManifestFinishedFiles($manifest, 1);
     $finishedFirstStat = $this->restProxy->getIngestManifest($manifest);
     $blobRestProxy->createBlockBlob($blob, $otherFileName, TestResources::MEDIA_SERVICES_DUMMY_FILE_CONTENT_1);
     $this->waitIngestManifestFinishedFiles($manifest, 2);
     $finishedSecondStat = $this->restProxy->getIngestManifest($manifest);
     // Test
     // Assert
     $contentKeysFromAsset = $this->restProxy->getAssetContentKeys($asset);
     $assetFiles = $this->restProxy->getAssetAssetFileList($asset);
     $this->assertEquals(0, $initialStat->getStatistics()->getFinishedFilesCount());
     $this->assertEquals(1, $finishedFirstStat->getStatistics()->getFinishedFilesCount());
     $this->assertEquals(2, $finishedSecondStat->getStatistics()->getFinishedFilesCount());
     $this->assertEquals($contentKey->getId(), $contentKeysFromAsset[0]->getId());
     $this->assertEquals($contentKey->getId(), $manifestFile1->getEncryptionKeyId());
     $this->assertEquals('true', $manifestFile1->getIsEncrypted());
     $this->assertEquals(EncryptionSchemes::STORAGE_ENCRYPTION, $manifestFile1->getEncryptionScheme());
     $this->assertEquals($initializationVector1, $manifestFile1->getInitializationVector());
     $this->assertEquals(Resources::MEDIA_SERVICES_ENCRYPTION_VERSION, $manifestFile1->getEncryptionVersion());
     $this->assertEquals($contentKey->getId(), $manifestFile2->getEncryptionKeyId());
     $this->assertEquals('true', $manifestFile2->getIsEncrypted());
     $this->assertEquals(EncryptionSchemes::STORAGE_ENCRYPTION, $manifestFile2->getEncryptionScheme());
     $this->assertEquals($initializationVector2, $manifestFile2->getInitializationVector());
     $this->assertEquals(Resources::MEDIA_SERVICES_ENCRYPTION_VERSION, $manifestFile2->getEncryptionVersion());
     // Files order is not static, so we don't know the index of each file and need to serve them as a set
     $resultFileNames = array($assetFiles[0]->getName(), $assetFiles[1]->getName());
     $this->assertContains($otherFileName, $resultFileNames);
     $this->assertEquals($asset->getId(), $assetFiles[0]->getParentAssetId());
     $this->assertContains($fileName, $resultFileNames);
     $this->assertEquals($asset->getId(), $assetFiles[1]->getParentAssetId());
 }
开发者ID:bitmovin,项目名称:azure-sdk-for-php,代码行数:75,代码来源:MediaServicesFunctionalTest.php

示例3: testCtrCryptInvalidInitializationVectorLength

 /**
  * @covers WindowsAzure\Common\Internal\Utilities::ctrCrypt
  */
 public function testCtrCryptInvalidInitializationVectorLength()
 {
     // Setup
     $data = 'Test data more than 16 bytes';
     $key = Utilities::generateCryptoKey(32);
     $initializationVector = '1234';
     $this->setExpectedException(get_class(new \InvalidArgumentException('')));
     // Test
     $actual = Utilities::ctrCrypt($data, $key, $initializationVector);
 }
开发者ID:southworkscom,项目名称:azure-sdk-for-php,代码行数:13,代码来源:UtilitiesTest.php

示例4: __construct

 /**
  * Create SymmetricTokenVerificationKey
  *
  * @return void
  */
 public function __construct()
 {
     $this->_keyValue = Utilities::generateCryptoKey(64);
 }
开发者ID:jwdunne,项目名称:azure-sdk-for-php,代码行数:9,代码来源:SymmetricVerificationKey.php

示例5: createCommonCBCTypeContentKey

function createCommonCBCTypeContentKey($restProxy, $encodedAsset)
{
    // 3.1 Generate a new key
    $aesKey = Utilities::generateCryptoKey(16);
    // 3.2 Get the protection key id for ContentKey
    $protectionKeyId = $restProxy->getProtectionKeyId(ContentKeyTypes::COMMON_ENCRYPTION_CBCS);
    $protectionKey = $restProxy->getProtectionKey($protectionKeyId);
    $contentKey = new ContentKey();
    $contentKey->setContentKey($aesKey, $protectionKey);
    $contentKey->setProtectionKeyId($protectionKeyId);
    $contentKey->setProtectionKeyType(ProtectionKeyTypes::X509_CERTIFICATE_THUMBPRINT);
    $contentKey->setContentKeyType(ContentKeyTypes::COMMON_ENCRYPTION_CBCS);
    // 3.3 Create the ContentKey
    $contentKey = $restProxy->createContentKey($contentKey);
    echo "Content Key id={$contentKey->getId()}" . PHP_EOL;
    // 3.4 Associate the ContentKey with the Asset
    $restProxy->linkContentKeyToAsset($encodedAsset, $contentKey);
    return $contentKey;
}
开发者ID:southworkscom,项目名称:azure-sdk-for-php,代码行数:19,代码来源:vodworkflow_drm_fairplay.php

示例6: createAssetDeliveryPolicy

function createAssetDeliveryPolicy($restProxy, $encodedAsset, $contentKey)
{
    // 5.1 Get the acquisition URL
    $acquisitionUrl = $restProxy->getKeyDeliveryUrl($contentKey, ContentKeyDeliveryType::BASELINE_HTTP);
    // 5.2 Generate the AssetDeliveryPolicy Configuration Key
    $randomKey = Utilities::generateCryptoKey(16);
    $configuration = [AssetDeliveryPolicyConfigurationKey::ENVELOPE_KEY_ACQUISITION_URL => $acquisitionUrl, AssetDeliveryPolicyConfigurationKey::ENVELOPE_ENCRYPTION_IV_AS_BASE64 => base64_encode($randomKey)];
    $confJson = AssetDeliveryPolicyConfigurationKey::stringifyAssetDeliveryPolicyConfiguartionKey($configuration);
    // 5.3 Create the AssetDeliveryPolicy
    $adpolicy = new AssetDeliveryPolicy();
    $adpolicy->setName('Asset Delivery Policy');
    $adpolicy->setAssetDeliveryProtocol(AssetDeliveryProtocol::SMOOTH_STREAMING | AssetDeliveryProtocol::DASH | AssetDeliveryProtocol::HLS);
    $adpolicy->setAssetDeliveryPolicyType(AssetDeliveryPolicyType::DYNAMIC_ENVELOPE_ENCRYPTION);
    $adpolicy->setAssetDeliveryConfiguration($confJson);
    $adpolicy = $restProxy->createAssetDeliveryPolicy($adpolicy);
    // 5.4 Link the AssetDeliveryPolicy to the Asset
    $restProxy->linkDeliveryPolicyToAsset($encodedAsset, $adpolicy->getId());
    print "Added Asset Delivery Policy: name={$adpolicy->getName()} id={$adpolicy->getId()}\r\n";
}
开发者ID:bitmovin,项目名称:azure-sdk-for-php,代码行数:19,代码来源:vodworkflow_aes.php

示例7: ContentKeyAuthorizationPolicy

$option = $restProxy->createContentKeyAuthorizationPolicyOption($option);
// 4.3 Create ContentKeyAuthorizationPolicy
$ckapolicy = new ContentKeyAuthorizationPolicy();
$ckapolicy->setName('ContentKey Authorization Policy');
$ckapolicy = $restProxy->createContentKeyAuthorizationPolicy($ckapolicy);
// 4.4 Link the ContentKeyAuthorizationPolicyOption to the ContentKeyAuthorizationPolicy
$restProxy->linkOptionsToContentKeyAuthorizationPolicy($option, $ckapolicy);
// 4.5 Associate the ContentKeyAuthorizationPolicy with the ContentKey
$contentKey->setAuthorizationPolicyId($ckapolicy->getId());
$restProxy->updateContentKey($contentKey);
print "Added Content Key Authorization Policy: name={$ckapolicy->getName()} id={$ckapolicy->getId()}\r\n";
// Phase 5 - Create the AssetDeliveryPolicy
// 5.1 Get the acquisition URL
$acquisitionUrl = $restProxy->getKeyDeliveryUrl($contentKey, ContentKeyDeliveryType::BASELINE_HTTP);
// 5.2 Generate the AssetDeliveryPolicy Configuration Key
$randomKey = Utilities::generateCryptoKey(16);
$configuration = [AssetDeliveryPolicyConfigurationKey::ENVELOPE_KEY_ACQUISITION_URL => $acquisitionUrl, AssetDeliveryPolicyConfigurationKey::ENVELOPE_ENCRYPTION_IV_AS_BASE64 => base64_encode($randomKey)];
$confJson = AssetDeliveryPolicyConfigurationKey::stringifyAssetDeliveryPolicyConfiguartionKey($configuration);
// 5.3 Create the AssetDeliveryPolicy
$adpolicy = new AssetDeliveryPolicy();
$adpolicy->setName('Asset Delivery Policy');
$adpolicy->setAssetDeliveryProtocol(AssetDeliveryProtocol::SMOOTH_STREAMING | AssetDeliveryProtocol::DASH | AssetDeliveryProtocol::HLS);
$adpolicy->setAssetDeliveryPolicyType(AssetDeliveryPolicyType::DYNAMIC_ENVELOPE_ENCRYPTION);
$adpolicy->setAssetDeliveryConfiguration($confJson);
$adpolicy = $restProxy->createAssetDeliveryPolicy($adpolicy);
// 5.4 Link the AssetDeliveryPolicy to the Asset
$restProxy->linkDeliveryPolicyToAsset($encodedAsset, $adpolicy->getId());
print "Added Asset Delivery Policy: name={$adpolicy->getName()} id={$adpolicy->getId()}\r\n";
// Phase 6 - Publish
// 6.1 Get the .ISM AssetFile
$files = $restProxy->getAssetFileList();
开发者ID:jeroenseegers,项目名称:azure-sdk-for-php,代码行数:31,代码来源:vodworkflow_aes_open.php


注:本文中的WindowsAzure\Common\Internal\Utilities::generateCryptoKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。