Exemple #1
0
        /// <summary>
        /// 驗證一個字串是否經過 MD5 編碼後會與傳入的 MD5 字串相符。可用來驗證使用者密碼。
        /// </summary>
        /// <param name="input">欲比較的字串。</param>
        /// <param name="hash">MD5 編碼過的字串。</param>
        /// <returns>若相符則傳回 True,否則傳回 False。</returns>
        public static bool MD5Verify(string input, string md5str)
        {
            // Hash the input.
            string hashOfInput = StrHelper.MD5Encode(input);

            // Create a StringComparer an comare the hashes.
            StringComparer comparer = StringComparer.OrdinalIgnoreCase;

            if (0 == comparer.Compare(hashOfInput, md5str))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
 /// <summary>
 /// Wraps the passed string at the total
 /// number of characters (if cuttOff is true)
 /// or at the next whitespace (if cutOff is false).
 /// Uses the environment new line
 /// symbol for the break text.
 /// </summary>
 /// <param name="input">The string to wrap.</param>
 /// <param name="charCount">The number of characters
 /// per line.</param>
 /// <param name="cutOff">If true, will break in
 /// the middle of a word.</param>
 /// <returns>A string.</returns>
 public static string WordWrap(string input,
                               int charCount, bool cutOff)
 {
     return(StrHelper.WordWrap(input, charCount,
                               cutOff, Environment.NewLine));
 }
Exemple #3
0
 /// <summary>
 /// Wraps the passed string at the
 /// at the next whitespace on or after the
 /// total charCount has been reached
 /// for that line.  Uses the environment new line
 /// symbol for the break text.
 /// </summary>
 /// <param name="input">The string to wrap.</param>
 /// <param name="charCount">The number of characters
 /// per line.</param>
 /// <returns>A string.</returns>
 public static string WordWrap(string input, int charCount)
 {
     return(StrHelper.WordWrap(input, charCount,
                               false, Environment.NewLine));
 }
Exemple #4
0
 /// <summary>
 /// 移除換行字元 (\n) 和 (\r)。
 /// </summary>
 /// <param name="input">輸入字串。</param>
 /// <returns>輸出字串。</returns>
 public static string RemoveNewLines(string input)
 {
     return(StrHelper.RemoveNewLines(input, false));
 }