Peter 4 mēneši atpakaļ
vecāks
revīzija
ccffac0423

+ 4 - 4
EasyDevCore.Common/Helper/CheckSumHelper.cs

@@ -164,7 +164,7 @@ namespace EasyDevCore.Common
             using (var encrypt = System.Security.Cryptography.MD5.Create())
             {
                 byte[] hash = encrypt.ComputeHash(stream);
-                return BitConverter.ToString(hash);
+                return hash.ToHex();
             }
         }
 
@@ -198,7 +198,7 @@ namespace EasyDevCore.Common
             using (var encrypt = System.Security.Cryptography.MD5.Create())
             {
                 byte[] hash = encrypt.ComputeHash(buffer, offset, count);
-                return BitConverter.ToString(hash);
+                return hash.ToHex();
             }
         }
 
@@ -222,7 +222,7 @@ namespace EasyDevCore.Common
             using (var encrypt = System.Security.Cryptography.SHA1.Create())
             {
                 byte[] hash = encrypt.ComputeHash(stream);
-                return BitConverter.ToString(hash);
+                return hash.ToHex();
             }
         }
 
@@ -242,7 +242,7 @@ namespace EasyDevCore.Common
             using (var encrypt = System.Security.Cryptography.SHA1.Create())
             {
                 byte[] hash = encrypt.ComputeHash(buffer, offset, count);
-                return BitConverter.ToString(hash);
+                return hash.ToHex();
 
             }
         }

BIN
EasyDevCore.Common/Helper/ConvertHelper.cs


+ 24 - 0
EasyDevCore.Common/Helper/DateTimeExtension.cs

@@ -23,6 +23,30 @@ namespace EasyDevCore.Common
             return DateTime.ParseExact(input.ToString(format), format, System.Globalization.CultureInfo.InvariantCulture);
         }
 
+        /// <summary>
+        /// Determines whether this instance is expired.
+        /// </summary>
+        /// <param name="input">The input.</param>
+        /// <returns>
+        ///   <c>true</c> if the specified input is expired; otherwise, <c>false</c>.
+        /// </returns>
+        public static bool IsExpired(this DateTime? input)
+        {
+            return input != null && input.Value > DateTime.Now;
+        }
+
+        /// <summary>
+        /// Determines whether this instance is expired.
+        /// </summary>
+        /// <param name="input">The input.</param>
+        /// <returns>
+        ///   <c>true</c> if the specified input is expired; otherwise, <c>false</c>.
+        /// </returns>
+        public static bool IsExpired(this DateTime input)
+        {
+            return input > DateTime.Now;
+        }
+            
         /// <summary>
         /// Gets the week of month.
         /// </summary>

+ 1 - 1
EasyDevCore.Common/Helper/StringExtension.cs

@@ -112,7 +112,7 @@ namespace EasyDevCore.Common
         /// <param name="input">The input.</param>
         /// <param name="len">The length.</param>
         /// <returns></returns>
-        public static string Right(this string input, int len) => (input == null || input.Length <= len) ? input : input.Substring(len - 1, input.Length - len);
+        public static string Right(this string input, int len) => (input == null || input.Length <= len) ? input : input.Substring(input.Length - len, len);
 
         /// <summary>
         /// Replaces with case style.

BIN
EasyDevCore.Common/Security/EncryptionHelper.cs