MD5.cs 652 B

1234567891011121314151617181920212223242526
  1. using System;
  2. using System.Text;
  3. namespace Essensoft.Paylink.Security
  4. {
  5. public static class MD5
  6. {
  7. public static string Compute(string data)
  8. {
  9. if (string.IsNullOrEmpty(data))
  10. {
  11. throw new ArgumentNullException(nameof(data));
  12. }
  13. using (var md5 = System.Security.Cryptography.MD5.Create())
  14. {
  15. var hash = md5.ComputeHash(Encoding.UTF8.GetBytes(data));
  16. #if NET5_0_OR_GREATER
  17. return Convert.ToHexString(hash);
  18. #else
  19. return BitConverter.ToString(hash).Replace("-", "");
  20. #endif
  21. }
  22. }
  23. }
  24. }