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


C# PgpPublicKey.GetValidSeconds方法代码示例

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


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

示例1: Load

        private void Load(PgpPublicKey key)
        {
            this.KeyId = key.KeyId.ToString("X");
            if (this.KeyId != null && this.KeyId.Length >= 15)
            {
                this.KeyIdShort = this.KeyId.Substring(this.KeyId.Length - 8);
            }
            this.Algorithm = key.Algorithm.ToString();
            this.BitStrength = key.BitStrength;
            this.IsMasterKey = key.IsMasterKey;
            this.IsEncryptionKey = key.IsEncryptionKey;
            this.Version = key.Version;
            this.CreatedOnUtc = key.CreationTime.ToUniversalTime();

            var validForSeconds = key.GetValidSeconds();
            if(validForSeconds > 0)
            {
                this.Expires = this.CreatedOnUtc.Value.AddSeconds(validForSeconds);
            }

            //this.ValidDays = key.ValidDays;
            //if (this.ValidDays.HasValue)
            //{
            //    this.Expires = this.CreatedOnUtc.Value.AddDays(this.ValidDays.Value);
            //}
            //else
            //{
            //    this.Expires = null;
            //}

            try
            {
                var userIds = key.GetUserIds();
                if (userIds != null)
                {
                    var enumerator = userIds.GetEnumerator();
                    if (enumerator.MoveNext())
                    {
                        var userIdentity = enumerator.Current as string;
                        if (userIdentity != null && userIdentity.Contains("<") && userIdentity.Contains(">"))
                        {
                            var name = userIdentity.Substring(0, userIdentity.IndexOf("<") - 1).Trim();
                            this.IdentityName = name;
                            var email = userIdentity.Substring(userIdentity.IndexOf("<") + 1);
                            email = email.Substring(0, email.IndexOf(">")).Trim();
                            this.IdentityEmail = email;
                        }
                    }
                }
            }
            catch { }

        }
开发者ID:compliashield,项目名称:compliashield-sdk-encryption,代码行数:53,代码来源:PgpPublicKeyMetaData.cs

示例2: IsKeyValid

		/// <summary>
		/// Perform basic validation of key. Check if revoked or expired.
		/// </summary>
		/// <param name="pubKey"></param>
		/// <returns></returns>
		public bool IsKeyValid(PgpPublicKey pubKey)
		{
			if (pubKey.IsRevoked())
				return false;

			// Check if key has expired
			if (pubKey.GetValidSeconds() != 0)
			{
				var expireTime = pubKey.CreationTime.AddSeconds(pubKey.GetValidSeconds());
				if (DateTime.Now > expireTime)
					return false;
			}

			return true;
		}
开发者ID:ALange,项目名称:OutlookPrivacyPlugin,代码行数:20,代码来源:PgpCrypto.cs


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