本文整理匯總了C#中System.Security.Cryptography.HashAlgorithm.ToKeyUriValue方法的典型用法代碼示例。如果您正苦於以下問題:C# HashAlgorithm.ToKeyUriValue方法的具體用法?C# HashAlgorithm.ToKeyUriValue怎麽用?C# HashAlgorithm.ToKeyUriValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Security.Cryptography.HashAlgorithm
的用法示例。
在下文中一共展示了HashAlgorithm.ToKeyUriValue方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetKeyUri
internal static string GetKeyUri(
OtpType type,
string issuer,
string account,
byte[] secret,
HashAlgorithm algorithm,
int digits,
long counter,
int period)
{
Contract.Requires<ArgumentOutOfRangeException>(Enum.IsDefined(typeof(OtpType), type));
Contract.Requires<ArgumentOutOfRangeException>(type != OtpType.Unknown);
Contract.Requires<ArgumentNullException>(issuer != null);
Contract.Requires<ArgumentOutOfRangeException>(!string.IsNullOrWhiteSpace(issuer));
Contract.Requires<ArgumentNullException>(account != null);
Contract.Requires<ArgumentOutOfRangeException>(!string.IsNullOrWhiteSpace(account));
Contract.Requires<ArgumentNullException>(secret != null);
Contract.Requires<ArgumentException>(secret.Length > 0);
Contract.Requires<ArgumentOutOfRangeException>(Enum.IsDefined(typeof(HashAlgorithm), algorithm));
Contract.Requires<ArgumentOutOfRangeException>(algorithm != HashAlgorithm.Unknown);
Contract.Requires<ArgumentOutOfRangeException>(digits > 0);
Contract.Requires<ArgumentOutOfRangeException>(counter >= 0);
Contract.Requires<ArgumentOutOfRangeException>(period > 0);
Contract.Ensures(!string.IsNullOrWhiteSpace(Contract.Result<string>()));
return
string.Format(
CultureInfo.InvariantCulture,
"otpauth://{0}/{1}:{2}?secret={3}&issuer={4}&algorithm={5}&digits={6}&counter={7}&period={8}",
type.ToKeyUriValue(),
HttpUtility.UrlEncode(issuer),
HttpUtility.UrlEncode(account),
Base32.Encode(secret),
HttpUtility.UrlEncode(issuer),
algorithm.ToKeyUriValue(),
digits,
counter,
period);
}