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


C# IKey.CreateEncryptorInstance方法代码示例

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


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

示例1: CanCreateAuthenticatedEncryptor

 private bool CanCreateAuthenticatedEncryptor(IKey key)
 {
     try
     {
         var encryptorInstance = key.CreateEncryptorInstance() ?? CryptoUtil.Fail<IAuthenticatedEncryptor>("CreateEncryptorInstance returned null.");
         return true;
     }
     catch (Exception ex)
     {
         _logger?.KeyIsIneligibleToBeTheDefaultKeyBecauseItsMethodFailed(key.KeyId, nameof(IKey.CreateEncryptorInstance), ex);
         return false;
     }
 }
开发者ID:leloulight,项目名称:DataProtection,代码行数:13,代码来源:DefaultKeyResolver.cs

示例2: CanCreateAuthenticatedEncryptor

 private bool CanCreateAuthenticatedEncryptor(IKey key)
 {
     try
     {
         var encryptorInstance = key.CreateEncryptorInstance() ?? CryptoUtil.Fail<IAuthenticatedEncryptor>("CreateEncryptorInstance returned null.");
         return true;
     }
     catch (Exception ex)
     {
         if (_logger.IsWarningLevelEnabled())
         {
             _logger.LogWarningF(ex, $"Key {key.KeyId:B} is ineligible to be the default key because its {nameof(IKey.CreateEncryptorInstance)} method failed.");
         }
         return false;
     }
 }
开发者ID:hishamco,项目名称:DataProtection,代码行数:16,代码来源:DefaultKeyResolver.cs

示例3: CreateCacheableKeyRingCoreStep2

        private CacheableKeyRing CreateCacheableKeyRingCoreStep2(DateTimeOffset now, CancellationToken cacheExpirationToken, IKey defaultKey, IEnumerable<IKey> allKeys)
        {
            Debug.Assert(defaultKey != null);

            // Invariant: our caller ensures that CreateEncryptorInstance succeeded at least once
            Debug.Assert(defaultKey.CreateEncryptorInstance() != null);

            _logger?.UsingKeyAsDefaultKey(defaultKey.KeyId);

            DateTimeOffset nextAutoRefreshTime = now + GetRefreshPeriodWithJitter(_keyManagementOptions.KeyRingRefreshPeriod);

            // The cached keyring should expire at the earliest of (default key expiration, next auto-refresh time).
            // Since the refresh period and safety window are not user-settable, we can guarantee that there's at
            // least one auto-refresh between the start of the safety window and the key's expiration date.
            // This gives us an opportunity to update the key ring before expiration, and it prevents multiple
            // servers in a cluster from trying to update the key ring simultaneously. Special case: if the default
            // key's expiration date is in the past, then we know we're using a fallback key and should disregard
            // its expiration date in favor of the next auto-refresh time.
            return new CacheableKeyRing(
                expirationToken: cacheExpirationToken,
                expirationTime: (defaultKey.ExpirationDate <= now) ? nextAutoRefreshTime : Min(defaultKey.ExpirationDate, nextAutoRefreshTime),
                defaultKey: defaultKey,
                allKeys: allKeys);
        }
开发者ID:yonglehou,项目名称:DataProtection,代码行数:24,代码来源:KeyRingProvider.cs


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