本文整理汇总了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;
}
示例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;
}
示例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;
}