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


C# SecureString.ToEncodedClearText方法代码示例

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


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

示例1: GetHash

 /// <summary>
 /// Gets the SHA512 of the password.
 /// </summary>
 /// <param name="password">the password to hash.</param>
 /// <param name="hashProvider">The hash provider.</param>
 /// <returns>The computed hash.</returns>
 private static byte[] GetHash(
     SecureString password,
     SHA512 hashProvider)
 {
     byte[] encodedText = password.ToEncodedClearText();
     try
     {
         return hashProvider.ComputeHash(encodedText);
     }
     finally
     {
         encodedText.Zero();
     }
 }
开发者ID:localtoast9001,项目名称:independent-sts,代码行数:20,代码来源:PasswordHash.cs

示例2: GetHash

 /// <summary>
 /// Gets the hash given the account id and secret.
 /// </summary>
 /// <param name="body">The raw body of the token.</param>
 /// <param name="secret">the secret for computing the hash.</param>
 /// <returns>the hash value.</returns>
 protected static byte[] GetHash(byte[] body, SecureString secret)
 {
     byte[] key = secret.ToEncodedClearText(Encoding.UTF8);
     try
     {
         using (HMACSHA256 sha = new HMACSHA256(key))
         {
             return sha.ComputeHash(body);
         }
     }
     finally
     {
         key.Zero();
     }
 }
开发者ID:localtoast9001,项目名称:independent-sts,代码行数:21,代码来源:Token.cs

示例3: Protect

        /// <summary>
        /// Encrypts a secure string with the given certificate.
        /// </summary>
        /// <param name="userData">the user data to encrypt.</param>
        /// <param name="certificate">the certificate for encryption.</param>
        /// <returns>the encrypted data.</returns>
        public static byte[] Protect(SecureString userData, X509Certificate2 certificate)
        {
            if (userData == null)
            {
                throw new ArgumentNullException("userData");
            }

            if (certificate == null)
            {
                throw new ArgumentNullException("certificate");
            }

            byte[] clearText = userData.ToEncodedClearText();
            try
            {
                return Protect(clearText, certificate);
            }
            finally
            {
                clearText.Zero();
            }
        }
开发者ID:localtoast9001,项目名称:independent-sts,代码行数:28,代码来源:CertProtectedData.cs


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