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


C# SecurityKey.IsSupportedAlgorithm方法代码示例

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


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

示例1: GetSignatureAlgorithm

        private static string GetSignatureAlgorithm(SecurityKey key)
        {
            // If key is null, an exception is thrown.
            if (key == null)
                throw new ArgumentNullException("key");

            // Set signatureAlgorithm to null.
            string signatureAlgorithm = null;

            // If the security key supports RsaSha1 then use that ...
            if (key.IsSupportedAlgorithm(SecurityAlgorithms.RsaSha1Signature))
                signatureAlgorithm = SecurityAlgorithms.RsaSha1Signature;
            // ... otherwise if it supports HMACSha1 use that ...
            else if (key.IsSupportedAlgorithm(SecurityAlgorithms.HmacSha1Signature))
                signatureAlgorithm = SecurityAlgorithms.HmacSha1Signature;

            return signatureAlgorithm;
        }
开发者ID:ssickles,项目名称:archive,代码行数:18,代码来源:SecurityTokenService.cs

示例2: GetEncryptionAlgorithm

        private static string GetEncryptionAlgorithm(SecurityKey key)
        {
            // If key is null, an exception is thrown.
            if (key == null)
                throw new ArgumentNullException("key");

            // Set encryptionAlgorithm to null.
            string encryptionAlgorithm = null;

            // If the security key supports AES256 use that ...
            if (key.IsSupportedAlgorithm(SecurityAlgorithms.Aes256Encryption))
                encryptionAlgorithm = SecurityAlgorithms.Aes256Encryption;
            // ... otherwise if it supports AES192 use that ...
            else if (key.IsSupportedAlgorithm(SecurityAlgorithms.Aes192Encryption))
                encryptionAlgorithm = SecurityAlgorithms.Aes192Encryption;
            // ... otherwise if it supports AES128 use that ...
            else if (key.IsSupportedAlgorithm(SecurityAlgorithms.Aes128Encryption))
                encryptionAlgorithm = SecurityAlgorithms.Aes128Encryption;

            return encryptionAlgorithm;
        }
开发者ID:ssickles,项目名称:archive,代码行数:21,代码来源:SecurityTokenService.cs

示例3: GetKeyWrapAlgorithm

        private static string GetKeyWrapAlgorithm(SecurityKey key)
        {
            // If key is null, an exception is thrown.
            if (key == null)
                throw new ArgumentNullException("key");

            // Set keywrapAlgorithm to null.
            string keywrapAlgorithm = null;

            // If the security key supports RsaOaep then use that ...
            if (key.IsSupportedAlgorithm(SecurityAlgorithms.RsaOaepKeyWrap))
                keywrapAlgorithm = SecurityAlgorithms.RsaOaepKeyWrap;
            // ... otherwise if it supports RSA15 use that ...
            else if (key.IsSupportedAlgorithm(SecurityAlgorithms.RsaV15KeyWrap))
                keywrapAlgorithm = SecurityAlgorithms.RsaV15KeyWrap;
            // ... otherwise if it supports AES256 use that ...
            else if (key.IsSupportedAlgorithm(SecurityAlgorithms.Aes256KeyWrap))
                keywrapAlgorithm = SecurityAlgorithms.Aes256KeyWrap;
            // ... otherwise if it supports AES192 use that ...
            else if (key.IsSupportedAlgorithm(SecurityAlgorithms.Aes192KeyWrap))
                keywrapAlgorithm = SecurityAlgorithms.Aes192KeyWrap;
            // ... otherwise if it supports AES128 use that ...
            else if (key.IsSupportedAlgorithm(SecurityAlgorithms.Aes128KeyWrap))
                keywrapAlgorithm = SecurityAlgorithms.Aes128KeyWrap;

            return keywrapAlgorithm;
        }
开发者ID:ssickles,项目名称:archive,代码行数:27,代码来源:SecurityTokenService.cs


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